matthiasbock / cantact-fw

Firmware source files for the CANtact USB-CAN-Bus-Adapter
http://cantact.io
Other
2 stars 1 forks source link

Unable to comunicate #11

Open liviuk2 opened 6 years ago

liviuk2 commented 6 years ago

I'm trying your version of the firmware on the CANtact hopping it solves some problems of freezing while writing, which I have with the original firmware.

Unfortunately I'm not even able to dump the messages on the CAN after I uploaded your firmware. Is there any different setup in order to use the device with your firmware?

matthiasbock commented 6 years ago

Thanks for reporting your issue. I can't reproduce your problem. The master branch works just fine for me.

Can you provide some more details please: Which commit did you compile? Are you sure, you flashed the firmware successfully? What state are the green and red LEDs? How did you up the device? How did you configure it? Which software did you use for capture?

liviuk2 commented 6 years ago

I've tried these two commits:

Are you sure, you flashed the firmware successfully?

I've connected the boot pins on the cantact and attached it to the usb. Than in the firmware dir I launched make flash. The final message was something like "download complete"

The green LED is ON

I've disconnected the boot pins and attached to the usb. First I've tried to use it with a python program (using pyserial library) which I normali use with the cantact with origina fw but didn't work so I've tried to connect to the serial interface with screen and manually send initialization command 'O' but nothing showed up, just blank screen. In the meanwhile the cantact was connected to a can bus with packets going on.

There is another procedure in order to flash the fw? There are others steps to perform initialization?

matthiasbock commented 6 years ago

If what you mean is, that the green LED is on, after you re-attached the device to USB after flashing, then the flashing was probably successful.

The way, you use the adapter sounds weird though. I assume, therein lies the problem. Please try again with slcand. Also, make sure, you match the bitrate to your bus.

liviuk2 commented 6 years ago

The way, you use the adapter sounds weird though. I assume, therein lies the problem. Please try again with slcand. Also, make sure, you match the bitrate to your bus.

Sorry, I forgot to say that I've also did these. Connected the device and run commands:

sudo slcand -o -c -s6 /dev/ttyACM0 can0
sudo ifconfig can0 up
candump can0

-s6 option since my bus is 500kbps. Al these in a VirtualMachine with Ubuntu 16.04, in the same virtual machine those commands successfully works with the origina firmware

But no message seen

matthiasbock commented 6 years ago

My first thought was, that you forgot to set filters for the CAN IDs you wish to receive, but as can be seen in https://github.com/matthiasbock/cantact-fw/blob/master/Src/can.c#L208 all frame IDs are received by default in the master branch.

On a side note, this is actually not the intended usage. The user/software should initially specify which frames should be received. I know, the official CANtact firmware is in "promiscuous mode" by default, too, but that's actually not how the CAN adapter should function. Especially not, since the used MCU is too slow to work under heavy frame load (at least in 1Mbps CAN networks).

Anyway, -s6 is evaluated in https://github.com/matthiasbock/cantact-fw/blob/master/Src/can.c#L257 and sets the prescaler according to the constants defined in https://github.com/matthiasbock/cantact-fw/blob/master/Inc/can_timing.h . I assume the error lies in an incorrect combination of bit segment and/or prescaler values. Please play around with those values. You could also check the configuration against http://www.bittiming.can-wiki.info/ (the hardware peripheral is called bxCAN)...