I am trying to communicate with a device using a serial port to usb connection. I am using the following code:
dev = DeviceOpen[ "Serial", {port, "BaudRate" -> 9600, "DataBits" -> 8,
"Parity" -> None, "Handshake" -> None, "StopBits" -> 1}]
I am getting a device object which says connected. (See the image below). However, I cannot get the data from the device (a list of 32 integers) when I use DeviceRead[dev]
or DeviceReadBuffer[dev]
which yield $Timeout
and an {}
list respectively.
An implementation of a small python code using the serial library gives the following list of 32 integers as expected:
Serial<id=0x3845160, open=True>(port='COM4', baudrate=9600, bytesize=8, parity='N',
stopbits=1, timeout=30, xonxoff=False, rtscts=False, dsrdtr=False)
sutterMP285: get status info
(64, 0, 2, 4, 7, 0, 99, 0, 99, 0, 20, 0, 136, 19, 1, 120, 112, 23, 16, 39, 80, 0, 0, 0, 25, 0, 4, 0, 200, 0, 46, 1)
There is clearly something wrong with Mathematica or the way i am handling things. Can someone help? Thanks !
the python code can be found at the following link: https://github.com/mgraupe/SutterMP285/blob/master/sutterMP285.py