collin80 / M2RET

GVRET fork to Macchina M2 board
MIT License
71 stars 21 forks source link

LAWICEL mode #9

Closed sprout42 closed 4 years ago

sprout42 commented 6 years ago

I was trying to get LAWICEL mode working on on an M2, I found that it worked fine if the SysSettings.lawicelMode variable is set to true. I was able to do this either by sending the 'V' command manually over the serial port, or by changing how the 'O' command was handled (although I suspect that this isn't the proper way to fix this behavior):

diff --git a/SerialConsole.cpp b/SerialConsole.cpp
index 740025d..5bb6b37 100644
--- a/SerialConsole.cpp
+++ b/SerialConsole.cpp
@@ -196,8 +196,8 @@ void SerialConsole::handleShortCmd()

     //Lawicel specific commands    
     case 'O': //LAWICEL open canbus port (first one only because LAWICEL has no concept of dual canbus
-        Can0.disable_autobaud_listen_mode();
-        Can0.begin(settings.CAN0Speed, 255);
+        //Can0.disable_autobaud_listen_mode();
+        //Can0.begin(settings.CAN0Speed, 255);
         Can0.enable();
         SerialUSB.write(13); //send CR to mean "ok"
         SysSettings.lawicelMode = true;

After making this change I was able to use slcand to be able to use the Linux socketcan utilities:

$ sudo slcand -o -c /dev/ttyACM0
collin80 commented 5 years ago

I've had another report that lawicel doesn't seem to be working. I'm going to try to replicate your fix and see if there's a better fix out there. Thanks.