normaldotcom / canable-fw

Firmware for the CANable USB to CAN adapter
http://canable.io/
Other
186 stars 73 forks source link

Stability of cantact-fw #5

Closed nexulm closed 5 years ago

nexulm commented 8 years ago

I've tried different commit versions: 1) latest master 2) master-branch = 13 commits behind 3) cantact-fw-037e7a9c6dcf14cfd30d424b72c245e71156782e (last one before changing to CAN interrupt handling) The firmware doesn't run stable on my STM32F072C8 (internal oscillator). I've adapt the Linker script .ld and .s files to the F072 type.

The uC seems to stop working what can be easily monitored with version 1) as the blinking LED stops blinking. With the master branch I've seen 25 Rx frames with ifconfig before the interface is frozen. With version 3) it stops after a max of 3 Rx messages and version 1) I've seen round about 5 CAN messages. I've modified the can init to 500kbit/s with prescaler = 12 instead of the original 125kbit/s. For all tests I'm using Vector CANoe which sends out only one frame (ID 123) with a cycletime of 1s@500kbit/s and a DLC=8. I'm using this USB2CAN interface (https://github.com/roboterclubaachen/usb2can) connected to a Raspberry Pi 1

Which commit version is the most stable one and/or what is the experience with the CANtact/CANable devices?

nexulm commented 8 years ago

I've used the fork from x893 now which is running with a busload of 90%@500kbit/s without freezing the STM32. Nevertherless I've observed that the slcan interface only receives 25% of the incoming messages. Within 2min I've 450646 Tx messages from Vector CANoe and the slcan interface shows and logs (candump -l slcan0) only 122293 Rx messages. :-( Maybe an issue of the missing IRQ Rx handling or the USB speed!?!

normaldotcom commented 8 years ago

Thanks for giving me a detailed description of the problem! CANables currently ship with firmware at rev fb0f55fd3beb5c66446def5f60fd6e1adcc1178b which you likely tested (~13 commits behind). The latest master is development code that isn't tested/proven yet, which I really should have done in a branch. With the stock firmware, were you seeing freezing after receiving 5 frames at 1 frame / second with the 13 behind firmware? That would be very strange... Regarding throughput, I think we verified over 80% busload performance at 500kbaud. I unfortunately don't have another 3rd party CAN adapter to test against at the moment to reproduce these results. Are you running the same clock configuration as the CANable with USB running from the internal oscillator, trimmed from USB? I'm also curious if you're having an issue similar to this.

nexulm commented 8 years ago

Yeah, for my USB2CAN interface with STM32F072 only the fork of X893 is running stable but with a lot of message losts. The USB2CAN is also using the internal HSI clock, I've changed nothing on the clock code. I've also used the "sudo apt-get –purge remove modemmanager" command mentioned by your issue link but the modemmanager isn't installed on my system. In the meantime I've playing around with two additional firmware version for STM32F0: 1) https://github.com/florolf/canable-socketcan

2) https://github.com/HubertD/candleLight_fw

I did a test on a BeagleBone Black (2x CAN SOC internal) and 1x USB2CAN with candleLight_fw at 90%@500kbaud = 0 message lost. The only point I've figured out that candump was not able to write all the data of 3x CAN to the internal BBB memory. Maybe a limition of the internal memory write speed. I'll check it soon against the SD-Card, an USB-Stick and an USB-HDD.

One point on the slcan side is still open for me: Is slcan a bottleneck for CAN throughput 90%@500kbaud or 90%@1Mbaud or not?

As soon as I've a CANable HW in my hands and figure out that the mentioned things are CAN2USB HW related I'll close the issue. But feel free to close the issue if you like.

Dark-Guan commented 7 years ago

I do some test on windows. It seems that the driver not receive all the data send to PC ,then allmost all message lost about 85%. I test on 1M CAN bus baudrate. @nexulm I think the problem is the driver. I test a USB data send and receive measurement program, It shows the most rate is about 80KB/s with no message missed. but when I use CANard with python it still lost about 85%.

Dark-Guan commented 7 years ago

@nexulm @normaldotcom I think I have figured out what is the problem. I use python to code. So I use CANard, which use "rx_str = rx_str + self.ser.read().decode('UTF-8', 'ignore')" to read from the system buffer , So it limits the speed. A lot of message is covered in the buffer, then there comes a lot of lot. I will update CANard and CANable/CANtact firmware ,then I will post the detail about the test. Thanks for all of you . This is amazing project!!!!

riodda commented 6 years ago

@nexulm Hi, can you give some more infor about the ems_usb firmware ? i'm using openwrt and struggling with the slcan driver, unfortnuatley on openwrt there is no gs_usb support yet, my only option is ems_usb. I see the device with ls_usb

root@OpenWrt:/# lsusb Bus 002 Device 004: ID 12d6:0444 EMS Dr. Thomas Wuensche CPC-USB/ARM7 But not sure if the kernel module is loaded properly

can_dev 8035 6 c_can,usb_8dev,peak_usb,kvaser_usb,esd_usb2,ems_usb ems_usb 6400 0

I've tryed to load the interface root@OpenWrt:/# ip link set can0 type can bitrate 250000 ip: either "dev" is duplicate, or "type" is garbage

normaldotcom commented 5 years ago

Closing this issue, latest changes and #7 have solved many performance limitations.