Can't get it to work with raw, only telnet

  • Hi!

    I've been experimenting a bit with this tool to control my surround receiver from my htpc and I have got it to work with telnet. But if I change the port config to raw, I can still connect using netcat, but I get no response. I run the command like this:

    ./ser2net -C "2000:telnet:600:/dev/ttyUSB0:9600 NONE 1STOPBIT 8DATABITS

    And on the other side I tried both manually running commands with netcat or just sending them like this:

    echo @VOL:1\r | nc -v spongebob 2000
    Connection to spongebob 2000 port  succeeded!

    As you see, I get a connection, but nothing happens. The surround receiver does not alter the volume. But as I said, it works fine with telnet. Any ideas?

  • Corey Minyard
    Corey Minyard

    I have no idea.  Well, I have some ideas, but nothing terribly definitive.

    telnet does some negotiation up-front; perhaps there is a delay in telnet and that makes it work?  You can try '(sleep 2; echo xxxx) | nc -v …..

    Also, when talking using telnet, you should really use the '-t' option to "nc".

    Beyond that, I don't know.  Could you try hooking something to the serial port to see the output in both cases?  Perhaps that would be helpful.

  • Ok, I will try sleeping a bit and see if it helps.

    I've been using the telnet command when using the telnet protocol, didn't know that netcat had an option for that too. Nice to know!

    Not sure if I have any computer with a serial port that I could read from. Is there any way to fake a serial port in linux that I could use with ser2net, just to debug? Could I get it to use stdout in some way?

  • Corey Minyard
    Corey Minyard

    You could simulate a serial port, but I'm pretty sure it wouldn't have the same effect.  Actually, ser2net has some tracing facilities if you set up a control port.  That was you could monitor what was being sent.  Perhaps nc is defaulting to telnet mode now and sending extraneous characters at the beginning as part of the telnet negotiation.

  • Ok, how to I enable this tracing you say? That would be really great. I'm considering writing a python script for this instead, just because it's easier to debug.

  • Corey Minyard
    Corey Minyard

    It's in the man page.  Basically, use "-p <port#>" to create the control port.  Then telnet to the control port and type "monitor tcp <port>" to monitor your port.

  • Thank you, that really helped! There were two problems apparently. I couldn't use port 2000 for some reason (even though I am root), but port 20000 worked and I could then see the other problem while monitoring. I forget the -e parameter for echo so that it escaped my \r. Now everything works fine! Thanks a lot for your help!