Write_raw and Bluetooth Connection Lost

38 views
Skip to first unread message

Jack Van Hoecke

unread,
Oct 7, 2016, 9:02:13 AM10/7/16
to OpenXC
Hello all,

I've written a significant amount of Python code for a project I am working on using your APIs as documented here: http://python.openxcplatform.com/en/master/api/controllers.html

It's actually working too :) but I am running into a problem with the Bluetooth connection dropping after sending a few hundred raw writes to the CAN. To me it looks like a memory leak or that some buffer might be filling up.

I came to this conclusion because when I effectively "pause" my writing before my connection drops, and then start it back up, it crashes around the same spot (hard to tell exactly). So you can either wait a long time in between the raw writes or run it straight through but end effect, my Bluetooth connection will drop around the same spot.

I've observed the data with some CANalyzer software/hardware and everything I am writing up until the point of my Bluetooth connection dropping is correct. A memory error does seem unlikely though given both my work on the Pi and your work on OpenXC run on Python which is very dynamic.

Thoughts?

Jack Van Hoecke

unread,
Oct 11, 2016, 8:41:14 AM10/11/16
to OpenXC
Switching to a USB implementation. Something odd to note, I didn't need to run my Python IDLE as root when using the Bluetooth interface, but I do for USB. It will return the error message saying that you don't have a device plugged in if you do not run as root.

Anyways. I did some thinking, and figured my data rate might be too high for Bluetooth? I long while ago I saw that Bluetooth for the Ford VI supports up to 250 Kb/s? But I think I've also seen someone say 25 Kb/s somewhere on the forums.. I was pulling around 80 Kb/s with my current firmware.

Ultimately I think switching to USB will just fix my current problems, we'll see if it causes any ;)

Eric Marsman

unread,
Oct 11, 2016, 10:14:18 AM10/11/16
to OpenXC
Hi Jack,

The RN42 supports 240Kb/s using SPP (http://ww1.microchip.com/downloads/en/DeviceDoc/rn-42-ds-v2.32r.pdf). That should give you 30KB/s, but our testing has shown it is closer to the 23-25KB/s range (http://vi-firmware.openxcplatform.com/en/master/advanced/binary.html#motivation).

Are you trying to do 80KBs or 80Kbs? 

Regards,
Eric

Jack Van Hoecke

unread,
Oct 18, 2016, 9:11:06 AM10/18/16
to OpenXC
Sorry for the delay. I meant to say 80KB/s (so bytes). So as expected, funny things happen when you go outside the spec.

I ended up switching off the Raspberry Pi, at least for the time being. I'm also just using USB. It seems more reliable and writes faster (for obvious reasons). I wasn't able to read reliably with USB on the Raspberry Pi for some reason..? I am able to use the exact same Python code on a laptop to read the CAN with a USB. I was able to use "openxc-dump" on the Pi's terminal with USB however, just not with the Python APIs.. Good news is, reading/writing worked with Bluetooth on both the Pi and laptop in Python.

I'll let you know if I figure it out. I'm thinking: mutex issue, CPU, USB ports, or differences in USB drivers.

Thanks for the reply though, I have everything working as intended for my project :)
Reply all
Reply to author
Forward
0 new messages