Hallo Blackjack,
das hat ja schonmal super funktioniert mit dem Comport. Vielen Dank.
Wenn du mir jetzt noch helfen könntest, die Inventory_G2 erfolgreich auszuführen, dann wäre ich restlos glücklich
Der folgende Code spuckt den Fehler 0x01 aus (Return before Inventory finished):
Code: Alles auswählen
from ctypes import byref, c_long, c_uint8, POINTER, WinDLL, c_ubyte, cast
READER_DLL = WinDLL('nameofdll.dll')
(
BAUD_9600,
BAUD_19200,
BAUD_38400,
_,
BAUD_56000,
BAUD_57600,
BAUD_115200
) = xrange(7)
class ReaderException(Exception):
def __init__(self, error_code):
Exception.__init__(self, 'Error code 0x{0:x}'.format(error_code))
self.error_code = error_code
def _error_check(result, _func, _arguments):
if result:
raise ReaderException(result)
return result
_auto_open_com_port = READER_DLL.AutoOpenComPort
_auto_open_com_port.argtypes = (
POINTER(c_long), POINTER(c_uint8), POINTER(c_uint8), POINTER(c_long)
)
_auto_open_com_port.restype = c_long
_auto_open_com_port.errcheck = _error_check
_Inventory_G2 = READER_DLL.Inventory_G2
_Inventory_G2.argtypes = (
POINTER(c_ubyte), c_ubyte, c_ubyte, c_ubyte, POINTER(c_ubyte), POINTER(c_long), POINTER(c_long), c_long
)
_Inventory_G2.restype = c_long
_Inventory_G2.errcheck = _error_check
def auto_open_com_port(port=8, com_address=0xff, baud=BAUD_57600):
port = c_long(port)
com_address = c_uint8(com_address)
baud = c_uint8(baud)
handle = c_long()
_auto_open_com_port(
byref(port), byref(com_address), byref(baud), byref(handle)
)
return port, com_address, baud, handle
def Inventory_G2(com_address, handle):
AdrTID=c_ubyte(0)
LenTID=c_ubyte(0)
TIDFlag=c_ubyte(0)
EPClenandEPC=(c_ubyte*5000)()
Totallen=c_long(0)
CardNum=c_long(0)
_Inventory_G2(
byref(com_address), AdrTID, LenTID, TIDFlag, cast(EPClenandEPC, POINTER(c_ubyte)), byref(Totallen), byref(CardNum), handle
)
print EPClenandEPC
return com_address, AdrTID, LenTID, TIDFlag, EPClenandEPC, Totallen, CardNum, handle
[port, com_address, baud, handle]=auto_open_com_port()
[com_address, AdrTID, LenTID, TIDFlag, EPClenandEPC, Totallen, CardNum, handle] = Inventory_G2(com_address, handle)
Kannst du nochmal helfen?