Communications problems solved

I wrote the attached program "keyboard.c" which sends an unbuffered keystroke to my Arduino DUE at 28800 baud.
The DUE is programmed with the attached "stepper_test.ino", which is a modification of the code provided by Sparkfun Electronics for the Big Easy stepper motor driver. My understanding is that, if I transmit over the "programming USB port" at 9600 baud, it will reprogram the DUE. However, since I am communicating at 28800 baud, communication should go as programmed.

My understanding is that if there is nothing to send, the request for input from the DUE (dueout in line 72 of the keyboard program) should result in a zero. Instead, I am getting bufr = 'k' (or some other random character).
??

PS Hopefully, someone else will find keyboard.c to be useful.

keyboard.c (3.08 KB)

stepper_test.ino (5.8 KB)

Some Linux kernels have a bug in their CDC driver when the baud rate is configured for 14400 or 28800 (which is silly, since the baud rate isn't really used).

Recommend using 38400 or any of the other standard rates.

Thank you.
In the process of changing the IO speed for the computer, I discovered that the command to change the IO speed was incorrect. B38400 actually equals 15. FYI, see attached corrected keyboard.c

Now I am getting different garbage in reply from the DUE.
Am I setting the communications speed incorrectly in the DUE sketch?

pjrc:
Some Linux kernels have a bug in their CDC driver when the baud rate is configured for 14400 or 28800 (which is silly, since the baud rate isn't really used).

Recommend using 38400 or any of the other standard rates.

keyboard.c (3.18 KB)

I would use the same baud rate used by the IDE to upload code. If the upload speed is 115200, set Serial.begin(115200) and open the serial console window at 115200. The menu should appear. Close the serial console window then run the keyboard program also running at 115200.

As far as I know 9600 is not a special baud except is it a lot slower than 115200. 1200 is a special baud rate which results in erase and reset of the board to get it ready for the next upload.

The Due has two micro USB ports. One is labelled the Programming port and the other the Native USB port. Both appear as USB serial ports to a computer. The programming port is connected to an ATmega16U2 and UART0 port so baud rate matters on this port. Baud rate does not matter on the native USB port because there is no UART.

I also would not use oddball baud rates such as 28800. I do not see any reason to use different speeds for upload versus serial console.

Menu?? I don't have any communication with the DUE board except thru the USB cable to the computer. And apparently, I don't have that communication either.

My keyboard program reports the existing flag settings prior to any changes. Thus, I know what flag settings the Arduino IDE uses during upload. I tried using those flag settings, and simply changed the communication speed from that used by the IDE. No joy. Still garbage from the DUE UART. I tried changing the connection from the programming port to the other USB port. No output from the DUE at all.

gdsports:
I would use the same baud rate used by the IDE to upload code. If the upload speed is 115200, set Serial.begin(115200) and open the serial console window at 115200. The menu should appear. Close the serial console window then run the keyboard program also running at 115200.

As far as I know 9600 is not a special baud except is it a lot slower than 115200. 1200 is a special baud rate which results in erase and reset of the board to get it ready for the next upload.

The Due has two micro USB ports. One is labelled the Programming port and the other the Native USB port. Both appear as USB serial ports to a computer. The programming port is connected to an ATmega16U2 and UART0 port so baud rate matters on this port. Baud rate does not matter on the native USB port because there is no UART.

I also would not use oddball baud rates such as 28800. I do not see any reason to use different speeds for upload versus serial console.

See if you can get this to work on the programming port. Upload it at whatever upload speed seems to work for you.

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println("Hello world!");
  delay(1000);
}

Open the serial console monitor (Ctrl-Shift-M). See the speed to 9600. Do you see anything? Try different speeds but the speed in Serial.begin(9600) must match the serial monitor speed.

If this does not work, something is broken on your system.

SUCCESS!
The trick was:

ack = read(USB, bufr +i++, 1);
if((ack < 0) && (errno == 11)){ // errno = 11 means device unavailable
  sleep(1);
  continue;
}

See if you can get this to work on the programming port. Upload it at whatever upload speed seems to work for you.

void setup() {

Serial.begin(9600);
}

void loop() {
  Serial.println("Hello world!");
  delay(1000);
}






Open the serial console monitor (Ctrl-Shift-M). See the speed to 9600. Do you see anything? Try different speeds but the speed in Serial.begin(9600) must match the serial monitor speed.

If this does not work, something is broken on your system.

Attached find a working, non-canonical interface between DUE board and USB port on a computer that is POSIX compliant (Apple, BSD, Linux). In other words, pressing a '1' key on the keyboard is immediately sent to the Arduino board, without accompanying new line character.
Although the interface is non-canonical (does not halt transmission pending carriage return), buffering is provided after receipt.

keyboard.c (5.04 KB)