Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctypes.c_byte to ctypes.c_ubyte fix #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,5 @@ Version History
- 2.2.0
- Added an optional loadCalibration parameter to the device open functions.
The open functions will now call getCalibrationData() by default.
- 2.2.1
- Fixed issue where ctypes.c_byte was used instead of ctypes.c_ubyte.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
]

setup(name='LabJackPython',
version='2.2.0',
version='2.2.1',
description='The LabJack Python modules for the LabJack U3, U6, UE9 and U12.',
license='MIT X11',
url='https://labjack.com/support/software/examples/ud/labjackpython',
Expand Down
12 changes: 6 additions & 6 deletions src/LabJackPython.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import Modbus


LABJACKPYTHON_VERSION = "2.2.0"
LABJACKPYTHON_VERSION = "2.2.1"
__version__ = LABJACKPYTHON_VERSION

SOCKET_TIMEOUT = 3
Expand Down Expand Up @@ -249,9 +249,9 @@ def _writeToExodriver(self, writeBuffer, modbus):
if modbus is True and self.modbusPrependZeros:
writeBuffer = [ 0, 0 ] + writeBuffer

newA = (ctypes.c_byte*len(writeBuffer))(0)
newA = (ctypes.c_ubyte*len(writeBuffer))(0)
for i in range(len(writeBuffer)):
newA[i] = ctypes.c_byte(writeBuffer[i])
newA[i] = ctypes.c_ubyte(writeBuffer[i])

writeBytes = staticLib.LJUSB_Write(self.handle, ctypes.byref(newA), len(writeBuffer))

Expand Down Expand Up @@ -371,7 +371,7 @@ def _readFromUE9TCPHandle(self, numBytes, stream, modbus):
return list(rcvDataBuff)

def _readFromExodriver(self, numBytes, stream, modbus):
newA = (ctypes.c_byte*numBytes)()
newA = (ctypes.c_ubyte*numBytes)()

if stream:
readBytes = staticLib.LJUSB_StreamTO(self.handle, ctypes.byref(newA), numBytes, 1500)
Expand Down Expand Up @@ -1824,9 +1824,9 @@ def eGetRaw(Handle, IOType, Channel, pValue, x1):
#Initialize newA
newA = None
if type(x1[0]) == int:
newA = (ctypes.c_byte*len(x1))()
newA = (ctypes.c_ubyte*len(x1))()
for i in range(len(x1)):
newA[i] = ctypes.c_byte(x1[i])
newA[i] = ctypes.c_ubyte(x1[i])
else:
x1Type = "float"
newA = (ctypes.c_double*len(x1))()
Expand Down
6 changes: 3 additions & 3 deletions src/u12.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ def write(self, writeBuffer):
raise U12Exception("The U12's handle is None. Please open a U12 with open().")

self._debugprint("Writing: " + hexWithoutQuotes(writeBuffer))
newA = (ctypes.c_byte*len(writeBuffer))(0)
newA = (ctypes.c_ubyte*len(writeBuffer))(0)
for i in range(len(writeBuffer)):
newA[i] = ctypes.c_byte(writeBuffer[i])
newA[i] = ctypes.c_ubyte(writeBuffer[i])

writeBytes = staticLib.LJUSB_Write(self.handle, ctypes.byref(newA), len(writeBuffer))

Expand All @@ -569,7 +569,7 @@ def read(self, numBytes=8, timeout=1000):
else:
if self.handle is None:
raise U12Exception("The U12's handle is None. Please open a U12 with open().")
newA = (ctypes.c_byte*numBytes)()
newA = (ctypes.c_ubyte*numBytes)()
readBytes = staticLib.LJUSB_ReadTO(self.handle, ctypes.byref(newA), numBytes, timeout)
# Return a list of integers in command-response mode
result = [(newA[i] & 0xff) for i in range(readBytes)]
Expand Down