kahiroka / slcanuino

USB-CAN(SocketCAN) sketch for Arduino CAN-BUS shield
125 stars 42 forks source link

Seems to be running commands when its not supposed to be #1

Open dayt0n opened 7 years ago

dayt0n commented 7 years ago

I uploaded this to my Arduino Uno with the same board as you have in the README, and as soon as it is plugged into my car (Chevy Volt 2014), it seems commands are being executed because messages will start popping up on the dash console. I did this twice. Last night, I did it and I didn't even have my computer connected to the board and when I plugged it into the car, the car started beeping at me and then started making a terrible whirring sound and wouldn't switch from gas to electricity. I called a car mechanic friend and he told me how to reset the computer. I thought I'd give it another shot this afternoon. I plugged the cable into the car and my computer, but the Arduino was still running the last software I had on it. I uploaded this software again, double checking that it didn't look like anything was going to go wrong, and as soon as it got done uploading, I saw about 2 messages on the dash console and immediately turned off the car. Is there any reason this kind of thing could be happening? I can, but I do not want to go out and buy a straight CAN->USB.

kahiroka commented 7 years ago

Hi. I recommend you to check basic functionality and communication between PC and Arduino before connecting them to your car. You can check it by typing O<Enter>, C<Enter>, V<Enter> and N<Enter> using a terminal emulation program e.g. Minicom with 1000000 baud rate and no hardware flow control setting. (Terminal emulation program and slcan are exclusive use.) You should see that a yellow LED on the CAN-BUS shield is turned on/off and 'V1234' or 'N1234' is displayed on the terminal if the communication is ok. It is possible that the default baud rate is not fit on your environment. In that case you need to set lower baud rate (921600, 576000, 500000, ...) to both the Arduino code and the application setting. For example:

slcan.ino

< Serial.begin(1000000);
> Serial.begin(921600);

slcan setting

< $ sudo slcand -S 1000000 ttyUSB0 can0
> $ sudo slcand -S 921600 ttyUSB0 can0

Please note that Serial Monitor of Arduino IDE forcibly set the rate to 115200 baud or lower, so you should not use it while connected.

dayt0n commented 7 years ago

Okay, so it seems the correct baud is 1000000. While this fixed the issue of the car doing weird stuff, I am still not able to view a candump. Orange light blinks and minicom works as you said, but when I run candump after running slcan_attach, slcand, and ifconfig up, I see nothing. I have also tried cansniffer and it just counts up but doesn't display anything. Any ideas? It does this with slightly lower baudrates as well, but it seems if i get too low, the car does weird stuff again. So I think 1000000 is the correct baud, I am just wondering why I am not seeing anything in candump or cansniffer.

I have tried plugging the cable into the car and then running the slcan commands and vice versa and neither seems to produce any effect on candump or cansniffer. Any advice?

Edit: I'm also pretty sure the Chevy Volt is 500kps so I don't think I need to change that part.

Edit 2: It also seems to be sending at least some data. I made a script that runs candump as soon as the device is enabled and it dumps a few packets, but stops shortly.

crossband commented 7 years ago

I have tried using Elecfreaks CAN shield v1.2 and Arduino UNO. With can-utils I had no success, it did not work. I was able to make it work with CANhack at 115200 baud, but stops after few seconds. I think Arduino UNO is too slow for such task.

I think it is worth to try with Arduino DUE.

kahiroka commented 7 years ago

I have no idea about this issue, but did you try arduino-canbus-monitor which is used as one of I/O modules in CANToolz? I hope it would be some of help.

crossband commented 7 years ago

I don't remember anymore. I have purchased CANable adapter from guy named Ethan Zonca and did not dig into any further. It is a clone of CANtact adapter for less price.

TaoOfJude commented 6 years ago

This issue looks similar to what I was experiencing. I'm connecting to the 2011 Jeep Wrangler, Arduino Uno, SparkFun Can shield, DB9 tied into the bus via the radio harness, RPi3. Connecting the can bus normally via Arduino, I have no issues. However, when trying to interface to the RPi I used the default commands in the ReadMe file. Bringing the system up would result in dash controls going wonky and the wipers would turn on inexplicably LOL. (I'm a noob with respect to tty, USB, serial, sockets and such). It turns out (after much noob-troubleshooting) that @kahiroka 's comment on 3/8/17 is correct in my instance; i.e. the baud rates were too high for my environment. Once I lowered them (and not sure how I'll know if they are too low) I began to see packet counts reported via $ ifconfig can0 then loaded up can-utils/cansniffer and had success! I do not know why a high setting would cause the odd vehicle behavior - I was not attempting to write any data. Great tools, lots of learning, thank you for the contribution.