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.

enter image description here

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)

enter image description here

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


I had this issue and it turned out the problem was related to the serial communication DTR signal. If this is the problem, a solution has been posted to this related question: Mathematica connection to Arduino *Micro*...any idea how to set DTR high?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.