Hello,
One problem has been annoying me as follows.
The following is a simple Leonard code doing the two jobs,
- Periodically sending "test" message to UART.
- Periodically toggling D0 digital port.
I monitored D0 pin by Oscilloscope and it started toggling when I download the code into Leonard.
Also, if I connecetd TeraTerm(terminal software) to Leonard via virtual COM,
it displayed "test" repeatedly. Until here, those were as expected.
Then, I closed teraterm and tried to connect C# UART program to Leonard via virtual COM.
Once I opened the COM port in my C#, D0 started to toggle more quickly and it means serial port is not available. (See the code below. Delay is larger.)
Then, I closed C# and connected TeraTerm back. It showed slower toggling again and "test" message is displayed correctly.
I compared serial com port setting between TeraTerm and C# but I did not see any difference.
DataBit=8bit, no parity, stopbit1, No handshake.
In C#, COM port status was "open" and no error when I run it.
Q1. Any idea why Serial status becomes not ready when C# tried to open serial com port?
Then, although Serial status was not ready, I tried to force to send text data to Leonard.
Leonard could catch the text message even with Serial not ready. However, sending text from Leonard to PC was still not success. I think it is because Serial status is not ready.
This behavior increased my doubt.
=== Code in Leonard =============================
int Data = 1;
void setup() {
pinMode(0, OUTPUT);
digitalWrite(0, Data);
Serial.begin(9600);
}
void loop() {
if(Serial) {
Serial.print("test\n");
delay(200);
} else {
delay(1);
}