Arduino Ethernet standard connection protocols ( to answer a few questions )

REALLY SIMPLE VERSION: I want to move a stepper motor an EXPLICIT # of steps ... using Ruby over LAN to an Ethernet shield ( w connected stepper ). ( if ALL protocols break stuff down into ASCII ... well i eat my foot and use atoi() )

" What are all of my options for connecting to an Arduino with the Ethernet shield ? " " How many different ways can I send information to an Arduino ? " " What are the supported protocols for Arduino and Ethernet communication ? " " What data can I send to my Arduino over a local area network ( LAN ) ? "

SO, I've been trying to get a project of mine to work .. and so far no luck. The bottle neck:

What languages ( packet protocols ) does the Arduino like?

Im asking about these:

HTTP / Serial / TELNET

TCP / UDP

.. and where does the generic arduino " Serial " fall into this list?

it seems that most of the examples use TELNET but I've got issues with how it chops up data and then I have to reconvert it into something usable

IE: run a atoi() on my arduino to get the integer variables im sending it

( this seems like a big waste of time to me... and I'd MUCH rather use a protocol that allows me to use " strict data types" )

when i say "strict data types" I mean:

  1. ruby application sends data ( var int = 98 ) over X protocol
  2. arduino reads data from X protocol
  3. data is read AS AN INTEGER .. and at a value of 98 (NOT ascii value = 19 929 182 .. then atoi(*l) )

... so what protocols support this?

What are all of my options for connecting to an Arduino with the Ethernet shield ?

You have two. One, the Ethernet shield can be plugged in. Two, the Ethernet shield can be unplugged.

It’s a pretty simple device to connect to the Arduino. It only fits one way.

How many different ways can I send information to an Arduino ?

Using the serial port, using I2C, and using SPI are the most common. The ethernet shield uses SPI to talk to the Arduino.

If the question was about data types, text and binary.

What are the supported protocols for Arduino and Ethernet communication ?

http is the most common.

What data can I send to my Arduino over a local area network ( LAN ) ?

Any data that you have.

What languages ( packet protocols ) does the Arduino like?

Im asking about these:

HTTP / Serial / TELNET

TCP / UDP

Languages and protocols and data content are three different things. The Arduino with ethernet shield can use all of the protocols (http, tcp, udp) and communications mechanisms (serial and telnet).

it seems that most of the examples use TELNET but I’ve got issues with how it chops up data and then I have to reconvert it into something usable

IE: run a atoi() on my arduino to get the integer variables im sending it

All communication with the Ethernet shield is in plain text. That is the nature of the protocols that the chip on the ethernet board understands.

( this seems like a big waste of time to me… and I’d MUCH rather use a protocol that allows me to use " strict data types" )

Conversion of text to integer is pretty quick. If you are going to use an ethernet shield on that Arduino, you are stuck with sending text to the shield.

If you want (or can) connect the Arduino directly to the PC, using the USB cable/serial port, there ishttp://ruby-serialport.rubyforge.org/, which allows you to send binary data to the Arduino.

Keep in mind, though, that an int on the PC and an int on the Arduino are not the same size, and that data sent over the serial port is in byte-sized chunks, so sending and receiving even something as simple as an int is not as easy as you want it to be.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1293708362

SO after reading this .. it seems that there is now a MULTI-BIT READ patch for the ethernet shield...

this is awesome

but im not ENTIRELY sure how to implement ?

.... results will follow .. lets hope i dont set something on fire !

I think I submitted my patch to Google Code and it's in. I don't know because I've been busy with other things and haven't played with my Arduino lately. I'll look into the status.

So I updated the following files:
Client.h

  virtual void write(const char *str);
  virtual void write(const uint8_t *buf, size_t size);
  virtual int available();

Client.cpp

int Client::read() {
  uint8_t b;
  if (!available())
    return -1;
  recv(_sock, &b, 1);
  return b;
}

size_t Client::read(uint8_t *buf, size_t size) {
  size_t av = available();
  if (size > av) {
    size = av;
  }
  if (size == 0) {
    return 0;
  }
  recv(_sock, buf, size);
  return size;
}

int Client::peek() {
  uint8_t b;
  if (!available())
    return -1;
  ::peek(_sock, &b);
  return b;
}

and now wondering how exactly to use this in a part of my arduino code…

from the soruce:

size_t Client::read(uint8_t *buf, size_t size)

so it would look like:
client.read(buffer,5)

… So could i get an example of this ? including all the other variables i need to get this to work?

Um. The code checked in (that will be available at the next release) is a little bit different. It returns 0 for closed connection and -1 for no data available. So I'm not sure I cam recommend that you use this version of the code. Look at issue 416: http://code.google.com/p/arduino/issues/detail?id=416

Maybe you should grab the checked-in version and use that.

Well. There's a problem with that also. I believe there's a bug that breaks the original Client::read(). I just commented on that in the issue. Sigh. That's the problem with using the latest stuff. If you want to get thing going sooner rather than later, drop me a note and I'll try to give you something that works.

I just read some of the older posts in this thread. There's nothing wrong with sending raw binary over a TCP connection. The Arduino library doesn't prevent it (in fact, has nothing to do with it either way).

So right now im interfacing the arduino C++ code with ruby ..

now im not 100% sure on the whole binary level transfer stuff .. but either way im thinking that ill be rewriting this protocol between the arduino and my ruby server a few times ... so i might as well get good at it..

so yeah!

feel free to be as verbose as possible, and let me know what i need to look into, to get these things to talk!

so i now understand the application of the binary

... now onto the decode of the commands from RUBY .. and encoding into C++ for the ardy

so two bytes one bit ..

1 byte = stepper selector 1 bit = sign for integer ( pos or neg ) 1 byte = number of steps to be stepped

this covers selecting the motor .. and which direction to step .. and how many steps

OK! i've got a working binary protocol

NOW onto filtering the arduino connections from the application requests

SO back to the question of 'what is an arduino ethernet connection?'

i know its capable of HTTP, but thats only if you build that into the request .. that being said what does it default to?