Hi Paul,
I'm experiencing a very very strange problem on one of the Teensy 3.0. My project has progressed a bit but recently found strange behavior on received bytes from Serial1. We often receive partial data and couldn't identify the source. We initially thought i was cabling issue, but every time when we reboot Teensy we'd be able to read about 10-20 bytes before it hangs somewhere. We are using baudrate 4800, which should be considered very low. I tested on other Teensy and with exactly the same .hex file, the other board doesn't have this issue. What could be the reason?
I have created a snippet which is able to demo the problem.
[pre]
void setup() {
Serial.begin(115200);
while (!Serial);
Serial1.begin(4800);
}
void loop() {
while (Serial1.available()) {
Serial.print("A: ");
Serial.println(Serial1.available());
Serial1.read();
}
}
[/pre]
The result is something like
A: 4
A: 3
A: 2
A: 1
A: 4
A: 3
A: 2
A: 1
A: 4
A: 3
A: 2
A: 1
A: 4
A: 3
A: 2
A: 1
A: 2
A: 1
And it hangs there despite I'm still feeding from serial controller.
The feeder program is as follows:
[pre]
#!/usr/bin/python
import serial
with serial.Serial('/dev/ttyUSB0', 4800, timeout=None) as ser:
while True:
ser.write('\xBC\xE9\x04\x33\x34\x38\x30\x88')
ser.write('\xBC\xEF\x08\xAC\x73\x14\x00\x40\x2D\x2F\x06\x78')
time.sleep(2)
[/pre]
My further investigation shows whenever Teensy meets time sleep, it will likely hangs there forever and every call to Serial1.available() would return 0 and any read from Serial1.read() will return -1.
We are using this to convert from a RS485 wire to 3.3V
https://www.sparkfun.com/products/10124
RX to RX, TX to TX with nothing else connected.
Teensy is powered by a ATX VSB which should be very stable at around 5.03V.
Very much willing to know what went wrong.
Regards,
Bai Shi
I'm experiencing a very very strange problem on one of the Teensy 3.0. My project has progressed a bit but recently found strange behavior on received bytes from Serial1. We often receive partial data and couldn't identify the source. We initially thought i was cabling issue, but every time when we reboot Teensy we'd be able to read about 10-20 bytes before it hangs somewhere. We are using baudrate 4800, which should be considered very low. I tested on other Teensy and with exactly the same .hex file, the other board doesn't have this issue. What could be the reason?
I have created a snippet which is able to demo the problem.
[pre]
void setup() {
Serial.begin(115200);
while (!Serial);
Serial1.begin(4800);
}
void loop() {
while (Serial1.available()) {
Serial.print("A: ");
Serial.println(Serial1.available());
Serial1.read();
}
}
[/pre]
The result is something like
A: 4
A: 3
A: 2
A: 1
A: 4
A: 3
A: 2
A: 1
A: 4
A: 3
A: 2
A: 1
A: 4
A: 3
A: 2
A: 1
A: 2
A: 1
And it hangs there despite I'm still feeding from serial controller.
The feeder program is as follows:
[pre]
#!/usr/bin/python
import serial
with serial.Serial('/dev/ttyUSB0', 4800, timeout=None) as ser:
while True:
ser.write('\xBC\xE9\x04\x33\x34\x38\x30\x88')
ser.write('\xBC\xEF\x08\xAC\x73\x14\x00\x40\x2D\x2F\x06\x78')
time.sleep(2)
[/pre]
My further investigation shows whenever Teensy meets time sleep, it will likely hangs there forever and every call to Serial1.available() would return 0 and any read from Serial1.read() will return -1.
We are using this to convert from a RS485 wire to 3.3V
https://www.sparkfun.com/products/10124
RX to RX, TX to TX with nothing else connected.
Teensy is powered by a ATX VSB which should be very stable at around 5.03V.
Very much willing to know what went wrong.
Regards,
Bai Shi