Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 2 FirstFirst 1 2
Results 26 to 42 of 42

Thread: Serial.rts() on Teensy 3.2

  1. #26
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,092
    Here's a (maybe) similar report, where RTS didn't work.

    https://forum.pjrc.com/threads/59612...l=1#post230233

    It turned out Coolterm works. The RTS issue appeared to be a bug in Moxa PComm Lite. Maybe it's doing the same thing at Termite?

  2. #27
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    664
    Wrote a short VB.NET program that can set the DTR & RTS lines individually and that worked also expected with a Teensy.
    Case closed I guess.

    Paul

  3. #28
    Junior Member
    Join Date
    Jan 2021
    Posts
    17
    There is a collection of ham radio apps that use RTS to key a transmitter. These all work with standard USB to serial port adapters like the FTDI. Of the four apps I tried, only one works to set RTS on the Teensy. Maybe there are two ways to assert RTS on Windows, and most apps use the way that doesn't work on the Teensy.

    I'm new to this, but it looks like your code that implements rts() is built on existing Arduino code, is that right? Where might I find the Arduino code to look at?

  4. #29
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,092
    Quote Originally Posted by smeredith View Post
    Maybe there are two ways to assert RTS on Windows, and most apps use the way that doesn't work on the Teensy.
    Yup, it sure looks that way.


    I'm new to this, but it looks like your code that implements rts() is built on existing Arduino code, is that right? Where might I find the Arduino code to look at?
    The problem is on the PC side. Nothing you can do on Teensy will help. The combination of Termite & the Windows driver simply isn't sending the control message. There is no way to fix this from the Teensy side, since Windows isn't sending any communication to Teensy when RTS changes in Termite.

    I did a test with a USB protocol analyzer, and tried to (rather awkwardly) record a video. It's uploading to YouTube now.

  5. #30
    Junior Member
    Join Date
    Jan 2021
    Posts
    17
    Is there a custom driver for the Teensy?

  6. #31
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,092
    Ok, here's the video demo. Sorry about the mediocre quality... not easy to shoot 2 screens and get exposure perfect (and I really need to get back to the bootloader chips... not time to do a more professional video production). If you play in HD quality viewing full screen, you should be able to see the protocol analyzer info.

    You can see whatever Termite is doing when you click the RTS button just isn't causing the Windows CDC-ACM serial driver to transmit anything to Teensy. But Coolterm does.


  7. #32
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,092
    Quote Originally Posted by smeredith View Post
    Is there a custom driver for the Teensy?
    No, for USB serial it's just the USBSER.SYS driver built into Windows.

    On Windows 10, it loads automatically. On Windows 2000, XP, 7 & 8, Windows doesn't load USBSER.SYS automatically. So a "driver" is installed on those systems, but it's not actually any executable code, just a text-only INF file which tells Windows to load its own USBSER.SYS driver when Teensy USB serial is detected.

    With MacOS and Linux, the USB serial driver is also built in and loads automatically.

    Teensy's many other non-serial USB modes also use the built in drivers on all 3 operating systems.

  8. #33
    Junior Member
    Join Date
    Jan 2021
    Posts
    17
    Thank you for your time and attention. I really appreciate it. I like that protocol analyzer.

    And you answered my question: there is no custom driver. Maybe the bug is in the Windows driver. Any maybe all the "unnecessary" work CoolTerm does when you click RTS works around the bug.

    Luckily, most of the apps I looked at (maybe all of them) let you choose between RTS and DTR as the transmit signal, and DTR is working reliably, so I'll be fine.

  9. #34
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    9,349
    I agree Paul. Windows works, i.e Powershell.
    The programs are buggy and maybe tested on FTDI only. The driver seems to be not 100% compatibel. Its more plausible that the bug is in the FTDI driver.
    The driver question was answered in Post19, too.

  10. #35
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,092
    My gut feeling is the guesswork on msg #28 is probably right. Microsoft probably only supported use of the modern WIN32 APIs in their USBSER.SYS driver. FTDI's driver probably has support for older Windows APIs (of which I know almost nothing).

    I mainly wanted to check whether any communication was happening from Windows to Teensy, to see if there could be any possibility of somehow making this work. It's really nice having the protocol analyzer for these situations, so we can know the issue is Windows simply isn't sending anything. Then I wanted to make a video... which turned into more setup and fiddling than I want to admit, even for such a low quality overexposed picture. Someday I'll get better at quick video demos... But right now, I need to get back to the bootloader chip's diagnostic feature so we can release T4 bootloader chips next week.

  11. #36
    Junior Member
    Join Date
    Jan 2021
    Posts
    17
    Quote Originally Posted by Frank B View Post
    I agree Paul. Windows works, i.e Powershell.
    The programs are buggy and maybe tested on FTDI only. The driver seems to be not 100% compatibel. Its more plausible that the bug is in the FTDI driver.
    CP2102-based adapters behave like the FTDI ones.

  12. #37
    Junior Member
    Join Date
    Jan 2021
    Posts
    17
    Maybe this has been a known issue for at least 9 years: https://answers.microsoft.com/en-us/...d-73865bc185f5

  13. #38
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    664
    @PaulStoffregen: not a boring video at all, very clear and informative!
    My guess is that the other mentioned terminal programs indeed talk to the FTDI driver instead of the WIN32 API.
    I recall that long ago I wrote programs for serial communications using an FTDI adapter and I was using FTDI's API. Like this:
    Code:
    ' FTD2XX.DLL functions
    Private Declare Function FT_Open Lib "FTD2XX.DLL" (ByVal intDeviceNumber As Short, ByRef intHandle As IntPtr) As Integer
    Private Declare Function FT_Close Lib "FTD2XX.DLL" (ByVal intHandle As Integer) As Integer
    Private Declare Function FT_SetDivisor Lib "FTD2XX.DLL" (ByVal intHandle As Integer, ByVal div As Integer) As Integer
    Private Declare Function FT_Read Lib "FTD2XX.DLL" (ByVal intHandle As Integer, ByVal lpszBuffer As String, ByVal lngBufferSize As Integer, ByRef lngBytesReturned As IntPtr) As Integer
    Private Declare Function FT_Write Lib "FTD2XX.DLL" (ByVal intHandle As Integer, ByVal lpszBuffer As String, ByVal lngBufferSize As Integer, ByRef intBytesWritten As IntPtr) As Integer
    Private Declare Function FT_SetBaudRate Lib "FTD2XX.DLL" (ByVal intHandle As Integer, ByVal lngBaudRate As Integer) As Integer
    Private Declare Function FT_SetDataCharacteristics Lib "FTD2XX.DLL" (ByVal intHandle As Integer, ByVal byWordLength As Byte, ByVal byStopBits As Byte, ByVal byParity As Byte) As Integer
    Private Declare Function FT_SetFlowControl Lib "FTD2XX.DLL" (ByVal intHandle As Integer, ByVal intFlowControl As Short, ByVal byXonChar As Byte, ByVal byXoffChar As Byte) As Integer
    Private Declare Function FT_ResetDevice Lib "FTD2XX.DLL" (ByVal intHandle As Integer) As Integer
    Private Declare Function FT_SetDtr Lib "FTD2XX.DLL" (ByVal intHandle As Integer) As Integer
    Private Declare Function FT_ClrDtr Lib "FTD2XX.DLL" (ByVal intHandle As Integer) As Integer
    Private Declare Function FT_SetRts Lib "FTD2XX.DLL" (ByVal intHandle As Integer) As Integer
    Private Declare Function FT_ClrRts Lib "FTD2XX.DLL" (ByVal intHandle As Integer) As Integer
    Private Declare Function FT_GetModemStatus Lib "FTD2XX.DLL" (ByVal intHandle As Integer, ByRef lngModemStatus As IntPtr) As Integer
    And yes, there can be an issue with the FTDI driver...

    Paul

  14. #39
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    664
    Quote Originally Posted by smeredith View Post
    Maybe this has been a known issue for at least 9 years: https://answers.microsoft.com/en-us/...d-73865bc185f5
    Well, that seems like the issue we see, but I assume usbser.sys is updated by now. Paul's video is quite convincing.

    Paul

  15. #40
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    9,349
    Again, Windows works, Powershell works. Coolterm works, other programs work.
    I programmed ESP over NodeMCU emulation running on Teensy - it uses both signals -> The Nodemcu programmer works too.
    Teensy uses a default driver built into Windows. Nothing by PJRC. Nothing what PJRC could do (besides writing an own driver - which is not wanted, I hope)

    I'm not sure which questions are still open..

  16. #41
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,092
    Quote Originally Posted by PaulS View Post
    but I assume usbser.sys is updated by now.
    Microsoft did fix some bugs in usbser.sys between Windows 8 to Windows 10, but apparently not this one.

  17. #42
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,092
    I've updated the Serial.rts() documentation on the website to mention this Windows bug, with a link to this thread.

    https://www.pjrc.com/teensy/td_serial.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •