mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-17 05:38:33 +03:00
Python script for serial usb card reader
This commit is contained in:
35
usb_application/serial_pysim.py
Executable file
35
usb_application/serial_pysim.py
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import usb.core
|
||||
import usb.util
|
||||
import sys
|
||||
|
||||
from pySim.transport.serial import SerialSimLink
|
||||
from pySim.commands import SimCardCommands
|
||||
|
||||
dev = usb.core.find(idVendor=0x03eb, idProduct=0x6004)
|
||||
|
||||
if dev is None:
|
||||
raise ValueError("Device not found")
|
||||
else:
|
||||
print("Found device")
|
||||
|
||||
print("dev.set_configuration(2)")
|
||||
dev.set_configuration(2)
|
||||
|
||||
cfg = dev.get_active_configuration()
|
||||
print("Active config: ")
|
||||
print(cfg)
|
||||
|
||||
if len(sys.argv) == 2:
|
||||
device = sys.argv[1]
|
||||
else:
|
||||
device='/dev/ttyUSB2'
|
||||
|
||||
baudrate='9600'
|
||||
|
||||
|
||||
sl = SerialSimLink(device, baudrate)
|
||||
scc = SimCardCommands(transport=sl)
|
||||
sl.wait_for_card()
|
||||
|
||||
Reference in New Issue
Block a user