How do I control an OutputPin through telnet?

Not sure if this should go here or the Interfacing section... Please move if I got it wrong!

I have spent hours researching the arduino but cannot figure out a simple question. How do I control a digital OutputPin through a telnet connection? All I want to do is set a pin HIGH or LOW through a telnet session. Ultimately, I would like to be able to do lots of things through telnet but this is a start. It would be best if I could actually pass single lines of raw code to the Arduino for it to then execute. Example: I would enter "digitalWrite(13, HIGH);" in the telnet session. If this is not possible then I guess I will have to build a program with predefined actions that respond to predefined keywords that are entered through the telnet connection. Example: I would enter "13ON" and the Arduino program would in turn execute a "digitalWrite(13, HIGH);"

1: I guess the main thing I need is the proper sketch to load into the Arduino (for the portion I have bolded above). The device initiating the telnet session (through USB) will NOT have any sort of driver, IDE, etc.
2: It will probably make sense after I see the sketch but an example of what telnet command to use for initiating a HIGH and LOW output to a specific pin would be nice.

If this works as expected I will probably drop on an xport so I can telnet over my network instead of through USB. This basic ethernet to serial "proxy" should do the trick: http://trac.mlalonde.net/cral/browser/branches/follower/libw5100/src/demo/simple_serial_proxy/simple_serial_proxy.pde

It would be best if I could actually pass single lines of raw code to the Arduino for it to then execute. Example: I would enter "digitalWrite(13, HIGH)"

However you do the comms, (USB or xportm etc) the AVR will be getting the commands through the serial port. You wold set up the serial port appropriately, and use Serial.read to grab a byte/char at a time.

As for send lines of raw code for the AVR to execute, this isn't possible. The C code is compiled before being loaded to to the AVR.

However you acn always write a parser to interpret the commands you send and act on them accordingly. If it were me I would shorten what you send from "digitalWrite(13, HIGH)" to something like "dw13h" or "dw13l". It would still be human readable and easy to parse by your program.

Mike

1: I guess the main thing I need is the proper sketch to load into the Arduino (for the portion I have bolded above). The device initiating the telnet session (through USB) will NOT have any sort of driver, IDE, etc.
[...]
If this works as expected I will probably drop on an xport so I can telnet over my network instead of through USB. This basic ethernet to serial "proxy" should do the trick: http://trac.mlalonde.net/cral/browser/branches/follower/libw5100/src/demo/simple_serial_proxy/simple_serial_proxy.pde

My observation is that you may be mixing your terminology somewhat.

By "telnet" do you mean using the actual "telnet" protocol (via the "telnet" program) or do you mean "by typing stuff on a command line"? One cannot "telnet" over USB but it is possible to have a serial connection over USB that enables one to "type stuff" and have that sent over serial to the device.

Also, be aware the ethernet-to-serial proxy you link to (which I wrote) was designed to work on the WIZ810MJ/WIZ811MJ boards, not an xport.

If you can clarify you needs more precisely, we may be able to help you further.

--Phil.

It would be best if I could actually pass single lines of raw code to the Arduino for it to then execute. Example: I would enter "digitalWrite(13, HIGH)"

However you do the comms, (USB or xportm etc) the AVR will be getting the commands through the serial port. You wold set up the serial port appropriately, and use Serial.read to grab a byte/char at a time.

As for send lines of raw code for the AVR to execute, this isn't possible. The C code is compiled before being loaded to to the AVR.

However you acn always write a parser to interpret the commands you send and act on them accordingly. If it were me I would shorten what you send from "digitalWrite(13, HIGH)" to something like "dw13h" or "dw13l". It would still be human readable and easy to parse by your program.

Mike

ok this makes sense. It makes sense to just create some shortened commands. I think I can work with that.

1: I guess the main thing I need is the proper sketch to load into the Arduino (for the portion I have bolded above). The device initiating the telnet session (through USB) will NOT have any sort of driver, IDE, etc.
[...]
If this works as expected I will probably drop on an xport so I can telnet over my network instead of through USB. This basic ethernet to serial "proxy" should do the trick: http://trac.mlalonde.net/cral/browser/branches/follower/libw5100/src/demo/simple_serial_proxy/simple_serial_proxy.pde

My observation is that you may be mixing your terminology somewhat.

By "telnet" do you mean using the actual "telnet" protocol (via the "telnet" program) or do you mean "by typing stuff on a command line"? One cannot "telnet" over USB but it is possible to have a serial connection over USB that enables one to "type stuff" and have that sent over serial to the device.

Also, be aware the ethernet-to-serial proxy you link to (which I wrote) was designed to work on the WIZ810MJ/WIZ811MJ boards, not an xport.

If you can clarify you needs more precisely, we may be able to help you further.

--Phil.

I actually meant telnet. I guess I forgot the difference between USB and serial.
The end goal is to have something that a linux machine can talk to via the execution of simple shell scripts. The scripts would ultimately control different relays. The linux machine cannot have any additional software, drivers, etc installed on it. (programming the arduino will be done on a different machine)

It would be nice to do this over the network eventually but figured I should try to get this working over USB first.

Does this sound right?

What you need is a command to bind the incoming telnet session on your unix system to the (usb) serial port that has the arduino on it. A sort of one-port "terminal server." It looks like "nc" (netcat) might be part of standard linux distributions, and might do what you need. See also "pastel", and presumably others.

What you need is a command to bind the incoming telnet session on your unix system to the (usb) serial port that has the arduino on it. A sort of one-port "terminal server." It looks like "nc" (netcat) might be part of standard linux distributions, and might do what you need. See also "pastel", and presumably others.

I am sorry that I did not clarify. The linux system running the control scripts will be the same system with the arduino connected to it. So technically there will be no network data needing to be passed to the arduino. The only exception being if/when I put an xport on the arduino of course.
The difference would be that on the local USB connection I would be telneting to the local serial port. With the xport I would be telneting to the IP interface of the xport.

You still need "nc" or equiv even if you're telneting from the local host; there is no such thing as "using telnet to the local serial port" without intermediate software. If you want the "telnet server" to behave just like an Xport, so you can't tell the difference between connecting when the arduino is connected locally vs when it is connected via the xport, you probably have a bit of work to do on the unix telnet server SW.