I'm working on a project where I need to control the PWM on multiple pins at the same time. I'm doing this on a Yun so I started out just trying something simple on the Neo. The problem, though, is that as soon as I connect to /dev/ttyMCC through either screen or minicom the kernel panics and the linux side locks up. The M4 does keep running though. I even tried modifying the M4 code to wait for the serial to be available but again, as soon as I connect using screen or minicom the kernel panics. The code and system specs I'm using are below. My next step is to just try to use the serial port without PWM and see what happens. Any thoughts? Kickstarter UDOO Neo Full UDOObuntu 2.0 RC2 - Clean install with all updates via "apt-get dist-upgrade" Code: /** * Variables to configure this system */ const int motorPins[] = { 3 }; void setup() { Serial.begin(115200); pinMode(13, OUTPUT); delay(100); } void loop() { while ( Serial.available() > 0 ) { Serial.write("Starting cylce"); for ( int i=0; i < sizeof(motorPins); i++ ) { Serial.write("ON "); Serial.write(i); Serial.write(":"); Serial.write(motorPins[i]); Serial.write("\n"); analogWrite(motorPins[i], 255); } Serial.write("Sleeping"); delay(10000); for ( int i=0; i < sizeof(motorPins); i++ ) { Serial.write("OFF "); Serial.write(i); Serial.write(":"); Serial.write(motorPins[i]); Serial.write("\n"); analogWrite(motorPins[i], 0); } Serial.write("Sleeping"); delay(10000); } delay(100); }
I'm not aware that there is a relation with using PWM. There are issues with serial though:http://www.udoo.org/docs-neo/Debugging_&_Troubleshooting/USB_stops_working_after_programming_M4.html
Yeah, I've looked through that and modified my code to not send serial data until connected. The bigger issue though is that I'm connecting through SSH, vs USB, and all comm to the linux side "dies" when the kernel panic occurs. I've also used the serial debug ports (46 & 47) and that is where I have seen that the kernel panics. I have yet to actually see the panic message to get a good dump.
I'm sorry. In my project I'm using Java RXTX to read M4 communication, and it works fine. I'm not using PWM, even though I can't see a relation with that. But that doesn't mean that there is none. For example, I'm having problems with a simple 4x7 display, where a PWM doesn't hang the display but a simple digitalWrite() does.
Looks like you're code is not coming anywhere: size motor pins is 1. So line i=0; i<1 ; i++ won't do anything.
Well, I finally got back to testing and solved the problem - definitely what I get for working late into the night and not paying attention. Apparently, if you use Serial.write vs Serial.print[ln] that is what makes the difference. Serial.write will cause a kernel panic immediately, Serial.print works just fine. I haven't dug into the details but that at least got my sketch working. Thanks for the help. Now back to hacking!
I tried a sketch lately that uses Serial.write() but no problems found there. Did not use an analogwrite though. Only read a sensor and pushed the data to A9.
Just tested this again. The root cause for the kernel panic is the Serial.write(i); line when i=0. Also Serial.write((int)i); did not solve the issue. On a real Arduino this should work (according google) on the Neo not. Edit: Tested and it works on an Arduino Uno! When I do a Serial.write(0); or Serial.write((int)0); I get a compiling error: /usr/share/arduino/hardware/UDOO/variants/udooneo/print.h:50:12: note: size_t Print::write(const char*) size_t write(const char *str) { ^ call of overloaded 'write(int)' is ambiguous If you modify the serial.write with serial.print as @Ed McLain did solves this issue but if you really want to send a zero byte you have a problem and the Neo freezes. So I think this should be addressed.
Looks like a workaround has been found: flush after sending a zero byte. More info: https://www.udoo.org/forum/threads/issue-with-serial0-write-0.5135t Edit: workaround is for Serial0 so for Serial it could not work.
Exactly, it does not work for Serial.write, it will still freeze the neo if you read from Serial where a zero was written to. Thats really bad! I would like to send an integer (uint16_t) to the Serial port. Minimal example that should work: int num = 1; byte *ptr_num = (byte*) # Serial.write (ptr_num, 2); So this should send two bytes (0x00, 0x01) but it will ignore the 0x00 and only send 0x01. If I would seperate the write into two consequtive byte sendings it would crash the neo: int num = 1; byte *ptr_num = (byte*) # Serial.write ((byte) ptr_num[0]); Serial.write ((byte) ptr_num[1]); Reading from the Serial on the Arm side now crashes the neo. Also a Serial.flush () does not help at all! How am I supposed to send raw data over the Serial Port, if zeros get ignored/crash the system?? Is there any advance in this issue?