psychopy.org | Reference | Downloads | Github

Serial coms in v 1.84.1

Hi,
Have you done something to change the serial port code in version 1.84.1 ?

I have a local version of the bits.py file which adds functionality for the Bits / Display++ triggers, digital IO and response box that I hope to make available to the community once I’m happy that it works. It relies on the serial port for communication with the CRS kit. All was fine in the 1.83.x versions but it fails with 1.84.1. The most obvious symptom is that this line of code throws an error.

self.com.setTimeout(timeout)

reporting that the com object has no member function setTimeout()

commenting that line out allows some coms to occur but I then get unexpected behavior when sending and receiving some messages. Eg

self.sendMessage(‘X’)
msg=self.read(0.1)

Should put the enable advanced mode for the RTBox mimic built into the Display++ and report back the device info for the RTBox. I don’t know if I’m achieving advanced mode but I am certainly not getting the expected message back.

Probably this is a change in pyserial. I think it got rid of commands like com.setTimeout (x) in favour of com.timeout = x

It certainly isn’t something that we’ve changed. Just a matter of the constant battle with dependencies.

Sorry, to the second part of the question, I’m not sure that this is a new issue but I would certainly insert a wait (say 0.01s?) after writing and before a read() just to give time for command to be received.

Thanks, updating code in line with pyserial 3 worked and yes it was poor coding to rely on the timeout to force a wait prior to reading so I’m now inserting waits.

1 Like