Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 15 of 15

Thread: How to receive serial data from Teensy when it is configured as Disk+Keyboard?

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    14

    How to receive serial data from Teensy when it is configured as Disk+Keyboard?

    Dear friends,

    I have configured Teensy's USB type to be Disk (SD card) + Keyboard. I hope to receive the serial data from Teensy. Although there is no USB type of Disk+Serial, I think this is possible because in Serial Monitor, I am able to see the messages.

    Under linux, my dmesg shows that Teensy is being recognized as Teensy Disk/Keyboard. No serial is mentioned. I have tried minicom on ttyS0 with no success.

    I have the following questions and wonder if you can help me:

    1, Is this actually possible? If possible in Teensyduino or C, could you give me some rough guidelines? If not, what would you recommend me to do to allow Teensy communicate back to the PC in the way SerialMonitor works?

    2, What port is Teensy recognized as under Linux? I looked at the preferences.txt, it says serial.port=COM1, which only makes sense in the context of Windows.

    Thanks for your help!

    Huan
    Last edited by liuhuan; 04-01-2013 at 02:40 PM.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,850
    For the non-serial USB types, a serial-like channel is emulated with HID. It's not serial at all, but HID.

    The "teensy_gateway" program runs in the background, listening for HID data from the Teensy and making it available via localhost networking, at 127.0.0.1:28541. You can connect to it with telnet. Use "telnet 127.0.0.1 28541". Teensyduino patches the serial monitor to connect to 127.0.0.1:28541 when used in this mode.

    So your easiest path would be using localhost networking to connect to the teensy_gateway program.

    A much more difficult path would be trying to splice the USB Disk and USB Serial code together. That might be possible, but it's not easy to edit the USB code.

  3. #3
    Junior Member
    Join Date
    Feb 2013
    Posts
    14
    Hi Paul,

    Awesome!!! The localhost networking approach works for me! Thanks so much!

    Huan

  4. #4
    Junior Member
    Join Date
    Feb 2013
    Posts
    14
    The teensy_gateway program is very sweet indeed. Is it opensource? Is its source included in teensyduino? I'd love to learn more about how it works!

  5. #5
    I have a similar question:
    I'm using a Teensy 2.0 in 'keyboard' mode & I want to send configuration data from my PC to the Teensy.
    The ideal way to do this would be to use 'disk(internal) + keyboard' and save the configuration data on the internal disk but unfortunately this will only work at compile time as the internal disk is read only from the PC on Teensy 2.0.
    Telnet would be an option but it doesn't seem to work bi-directionally, or at least not with Serial.read() on the Teensy side.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,850
    Quote Originally Posted by ian View Post
    Telnet would be an option but it doesn't seem to work bi-directionally, or at least not with Serial.read() on the Teensy side.
    That should work. First, try sending with the Arduino Serial Monitor.

  7. #7
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Hi

    I pretty new to teensy world. But is it not possible simply to connect to the uart port ?

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,850
    Quote Originally Posted by sasha View Post
    But is it not possible simply to connect to the uart port ?
    Yes, but this does require another USB-to-serial device or cable.

  9. #9

    done that

    Quote Originally Posted by PaulStoffregen View Post
    That should work. First, try sending with the Arduino Serial Monitor.
    I'm using putty on a W7 machine (no native telnet)
    I receive ok but Teensy seems deaf. I've also tried connecting via a browser (firefox) - I can dump data to the browser but my app doesn't see the http GET

  10. #10
    Quote Originally Posted by sasha View Post
    Hi

    I pretty new to teensy world. But is it not possible simply to connect to the uart port ?
    Sasha,

    I think Paul summed this up. My application is a USB data logger of sorts - it plugs in via USB and dumps data as if it were a keyboard, however I want the user to have control of certain parameters.

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,850
    Quote Originally Posted by ian View Post
    I'm using putty on a W7 machine (no native telnet)
    http://technet.microsoft.com/en-us/l...=ws.10%29.aspx

  12. #12
    Just the same as putty. Teensy transmits but doesn't receive.
    Oops - I lied! It does work! I'm not sure what I was doing wrong with putty...
    However, this still isn't ideal as it requires the end user to have the Teensy gateway.
    Last edited by ian; 04-06-2013 at 02:19 PM. Reason: correction

  13. #13
    Junior Member
    Join Date
    Feb 2013
    Posts
    14
    Quote Originally Posted by ian View Post
    Just the same as putty. Teensy transmits but doesn't receive.
    Oops - I lied! It does work! I'm not sure what I was doing wrong with putty...
    However, this still isn't ideal as it requires the end user to have the Teensy gateway.
    Hi guys,

    I'm having the same problem as Ian described earlier: I can receive data from Teensy, but cannot send via the socket. I tried to use the telnet program in Ubuntu and use the python socket library, both could receive fine, but none of the data could be received by teensy.

    The IP and port I used are: 127.0.0.1 and 28541.

    The USB mode is: SD card + keyboard.

    Any idea? Maybe there's some subtle difference between the telnet implementation in windows and others?

    Thanks!
    Last edited by liuhuan; 10-07-2013 at 10:42 AM.

  14. #14
    Junior Member
    Join Date
    Feb 2013
    Posts
    14
    Quote Originally Posted by PaulStoffregen View Post
    For the non-serial USB types, a serial-like channel is emulated with HID. It's not serial at all, but HID.

    The "teensy_gateway" program runs in the background, listening for HID data from the Teensy and making it available via localhost networking, at 127.0.0.1:28541. You can connect to it with telnet. Use "telnet 127.0.0.1 28541". Teensyduino patches the serial monitor to connect to 127.0.0.1:28541 when used in this mode.

    So your easiest path would be using localhost networking to connect to the teensy_gateway program.

    A much more difficult path would be trying to splice the USB Disk and USB Serial code together. That might be possible, but it's not easy to edit the USB code.
    Hi Paul,

    Since I'm having trouble sending data to Teensy while it's in USB Disk+USB Keyboard mode, I'd like to try the difficult path. Can you give some hints/guidelines on how to do this? Thanks!

  15. #15
    Junior Member
    Join Date
    Feb 2014
    Posts
    11
    Hi paul,

    I was wondering how can I have multiple Teensys connected to the same computer and have their data sent over? Is the teensy gateway program capable of receiving data from multiple Teeensys on the same localhost port?

Posting Permissions

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