Unable to access COM ports after Bonsai crash

391 views
Skip to first unread message

Sebastian Wittekindt

unread,
Jan 28, 2021, 3:15:24 PM1/28/21
to Bonsai Users
Hello,

I'm working on a closed loop tracking pipeline for C. elegans, which requires a lot of debugging and such. I'm having an annoying issue where anytime Bonsai crashes or closes, or I terminate the run it seems to not be ending its subscription to the port I am using, resulting in me getting an error the next time I try to access the port. The solution I've found is just to unplug the USB cord every time but I would like to understand why Bonsai isn't terminating the connection properly.

Any suggestions are appreciated!

Gonçalo Lopes

unread,
Feb 7, 2021, 12:12:16 PM2/7/21
to Sebastian Wittekindt, Bonsai Users
Hi Sebastian,

To understand what is happening exactly, we would need to understand the nature of the serial device with which you are communicating via Bonsai. Is it an Arduino? some other microcontroller? The behavior of the device will determine its robustness to serial port failures.

Also, in general I would separate the error behavior from successful termination. If successful termination is failing to close the port, indeed this should be investigated first (and deal with the error cases after).

In any case, if you could post a minimal workflow that reproduces this situation it would be really helpful for us to understand what is going on.

Hope this helps.

--
You received this message because you are subscribed to the Google Groups "Bonsai Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/c1084c9d-1184-4c62-95bf-5845e008b594n%40googlegroups.com.

Sebastian Wittekindt

unread,
Feb 11, 2021, 9:40:49 PM2/11/21
to Bonsai Users
Hi Goncalo,

I am using two Zaber linear actuators/stages. Please see the attached screenshot of my Bonsai workflow. The TAW script Python node writes the commands to the USB port COM4.

Hope this helps and thanks for your time!
-Sebastian

image.png

bruno...@neuro.fchampalimaud.org

unread,
Feb 12, 2021, 4:45:05 AM2/12/21
to Bonsai Users
Hey, 
I wonder.... If you are using python to interface with your device (Not sure, since I can't see the code inside your python node =( ), you probably need to close that port before you end bonsai too. If you don't have a strong reason to use python to interface with your devices, Bonsai has built-in nodes (CreateSerialPort, SerialStringRead, SerialStringWrite) that make this process much easier (including closing the port once the workflow stops running).
Cheers,
Bruno

Vincent Prevosto

unread,
Apr 21, 2021, 5:04:34 PM4/21/21
to Bonsai Users
Hi Sebastian,
A bit tangential , but I wanted to ask: would you be ok to share your workflow? We have a somewhat similar code in Matlab for controlling the Zaber actuators (very different experiments: mouse tactile perception), and I'd be curious to test (and help debug if needed?) your Bonsai workflow.
Thanks,
Vincent

Sebastian Wittekindt

unread,
Apr 21, 2021, 5:23:25 PM4/21/21
to Vincent Prevosto, Bonsai Users
Hi Vincent,

Yes for sure. In our workflow the TAW Script python node is what writes commands to the zaber node. Let me know if you have any luck figuring it out. 

Thanks,
-Sebastian

You received this message because you are subscribed to a topic in the Google Groups "Bonsai Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bonsai-users/U0XxbvtuCuY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bonsai-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/a7221976-6faa-447d-b4fa-1260e9b66631n%40googlegroups.com.
TrackingScopeUpdated.bonsai

Vincent Prevosto

unread,
Apr 21, 2021, 5:59:47 PM4/21/21
to Bonsai Users
Hi Sebastian,
Thanks! Very useful.
On first read, I don't see a way to integrate Bonsai built-in Serial nodes as Bruno suggested. I'll do some tests next week and let you know.
Thanks,
Vincent

Sebastian Wittekindt

unread,
Apr 23, 2021, 3:41:27 PM4/23/21
to Bonsai Users
For sure!

Let me know what you find pls.
-Sebastian

Reply all
Reply to author
Forward
0 new messages