Resetting Teensyduino Serial

Status
Not open for further replies.

tlb

Well-known member
Is there any other way to reset Teensyduino serial other than re-booting my PC?

I am attempting to get an Arduino program running on a Teensy 2.0 that talks to a Python Serial (pyserial) program running on Windows XP. I'm new to both Arduino and pyserial(have used other Python programming), so working thru the debug process.

I can get Teensyduino to communicate over a test program to the Arduino serial monitor. The target program also communicates to the serial monitor. It is on COM7. Arduino shows COM4 and COM7 active. When running pyserial, I don't receive any communications and the Python program hangs. And then when I look on the Arduino window it no longer shows COM7, only COM4. I have tried unplugging USB, re-loading the program, re-starting programs and I can't get COM7 back without re-booting the PC. Quite irritating :-(

BTW, does the baud rate in Serial.begin(115200) have any effect for USB serial? There is some mis-match between the various 'sketches' and the Python program. Something to try after I re-boot my PC ...

Thx,

TLB
 
I can get Teensyduino to communicate over a test program to the Arduino serial monitor. The target program also communicates to the serial monitor. It is on COM7. Arduino shows COM4 and COM7 active. When running pyserial, I don't receive any communications and the Python program hangs. And then when I look on the Arduino window it no longer shows COM7, only COM4. I have tried unplugging USB, re-loading the program, re-starting programs and I can't get COM7 back without re-booting the PC. Quite irritating :-(

Sadly, the Windows serial driver is not very good. It has bugs where unexpected removal of the device causes it to leave garbage in the Windows registry, and then the next time the device appears, it won't be recognized. The problem where you have to reboot is very likely due to this bug in Windows. Sadly, it's the same bug in every version, so upgrading to Windows 7 or 8 will not help. I put a lot of work into trying to avoid this Windows bug when you use the Serial Monitor and the Upload button (there's a special delay in the Teensy code, just to avoid this Windows bug). But if you use another program and reboot the Teensy, especially by pressing the button rather than letting Arduino send the reboot request, there's not much I can do. The only real solution is to quit or close the port from pyserial before you reboot Teensy.

This stuff is rock-solid on Mac and Linux. If you have a Mac or can use Linux, it really does work much better than Windows.

The other issues you're seeing are probably the locking mechanism which is intended to allow only a single program to access the device. If pyserial has the port open, then Arduino can't open it. If the port isn't available (in use by another program), it will not appear in Arduino's Tools > Serial Port menu. That's actually supposed to be a feature. It would be much nicer if it showed but was gray/disabled, but nobody has figured out how to make Arduino do that (the serial library Arduino uses doesn't support such things).




BTW, does the baud rate in Serial.begin(115200) have any effect for USB serial?

No, the baud rate has absolutely no effect. Well, except for one thing....

The baud rate is never actually used. No matter what baud rate you set, the data is always transferred at 12 Mbit/sec. USB has built-in flow control, so it will never try to send data faster than you can receive it. The actual speed depends on the speed of the software on both sides. In practice, using simple Arduino-like coding, usually about 120 to 300 kbytes/sec is about as fast as Teensy 2.0 can go. It's much faster than only 11.52 kbytes/sec!

However, there is one small baud rate effect. Whatever baud rate you've set on the PC can be read with Serial.baud() on the Teensy side. Likewise, the number of bits, parity and other settings that aren't ever used can be read, so you can find the PC settings. That's useful if you're going to resend the data over a real serial port, where you want to configure it to match the PC's settings.
 
Status
Not open for further replies.
Back
Top