So I have been working on this project for a few weeks now and it contains 2 arduinos and an ethernet shield. Long story short I am very close to running out of room on the arduino with the ethernet shield and need to send a string containing information for more functionality to another arduinio. I intend on doing this with softwareSerial. However, I cannot seem to get it to function. I have tried many other workarounds such ass Easy Transfer and I2C, but none of these work.

The first arduino has an Ethernet shield and has its own power source. Pin 2 is connected to Pin 3 of the second arduino, Pin 3 is connected to Pin 2 of the other arduino and the arduinos are connected with a common ground. The second arduino also has its own power source. (I have also tried powering the second arduino with the first, but it produces the same result.)

basically whenver I attempt to send a char array from the first arduino to the second, the second does not recgonize that there is incoming data. Can anyone help me with this bug? Code below (ethernet code removed).

When talking tbetween arduinos, using small nibbles of bits and bytes to send binary type data is far more efficient. Less to send & less room needed in ram. An arduino doesn't read text so the receiving end still has to interpret the data,

also sBuffer is empty, you initialise it and send it with out defining any content. If variables are defaulted to 0 then the first character is the terminator.

Edit: hmmm,just read your post over again, if you were sending valid string data that is terminated properly, you only should be sending the actual data length, not the entire array as previous data could be in the buffer after the null.

I'm not familiar with the arduino serial library, but the library code doesn't seem to be the problem.

Here is the full code as requested.The sBuffer is being filled previously in the code on Arduino 1 (around line 190) and right before I send it over serial, it is printed to the SerialMonitor over USB. This is how I know its terminated properly due to the fact that I dont get garbage in the Serial Monitor.

The serial sending is at the bottom of Arduino 1 code and in a function called sendMessgeToSlave.

An example of what the first arduino gets is"http://192.168.1.62/lights.htm?house=A&dev=02&ctrl=0" --from web browserIt then extracts the url and checks for special cases and to see if the file exists on sd.. if it does it will return it to the client....then the rest of the input containing "?house=A&dev=02&ctrl=0" is then parsed out and stored in sBuffer. I then calculate the length of the string and add in the null terminator being sBuffer[end] = NULL; This is around line 193 on arduino 1.

**The other thing that I may be causing the issue, but I cannot seem to find if it actually is, and I dont believe it is, is the var requestPos. I use this var to store different things at different times as a work around to help with the flash storage issue I am having. But like I said, I could not find anything wrong with it.

I do know that more or less I will actually be getting ascii encoding over this line and reading on arduino 2. I have managed this before. My issue is that the Message Avail is never actually printed, thus the second arduino is not getting the message. So this means, to me at least, that I am not getting softSerial to work properly.

if(ss.available()) { Serial.print("Message Avail"); Serial.print(ss.read()); Serial.write(ss.read()); }If there is a byte to read, read both of them. Well, that's not how it's usually done. Rather, that's not how it's correctly done.

There is noting I can really do about the link.... That how this project works.. it uses the ethernet shield. That url is read in from the client as a HTTP request..... i could post that

the Serial.print is printing the whole array (up until the NULL termination) that is how the Serial Print in arduino IDE 1.0 (and if i remember most standard c libs) work. It is printing what I expect: "?house=A&dev=02&ctrl=0" after the zero there is a null termination. This causes the char array to act like (how i see it) a streaming string. It will stop at the Null termination.

As for the 2nd arduino read, one of those are supposed to be commented out as well as the same version in the arduino 1 code. I dont know why the comment didnt copy. but they essentially should be XOR'd.

Below is the http request that the ethernet server will get... the lights.htm is indeed located on the sd card and the client receives the HTTP 200 version of the request

Quote

GET /lights.htm?house=A&dev=02&ctrl=1 HTTP/1.1Ho

That is the readRequest buffer after it fills.. and was generated but the URL:

the Serial.print is printing the whole array (up until the NULL termination) that is how the Serial Print in arduino IDE 1.0 (and if i remember most standard c libs) work. It is printing what I expect: "?house=A&dev=02&ctrl=0" after the zero there is a null termination. This causes the char array to act like (how i see it) a streaming string. It will stop at the Null termination.

That was my point. The printing stops at the NULL. But, that is NOT haw you are sending serial data. You are sending the entire array - all 50 elements.

If you comment out the x10 stuff on Arduino 2, does that change the behavior of Arduino 2?

If you connect Arduino 1 to the hardware serial pins on Arduino 2, and blink and LED when you get serial data, does the LED ever blink?

I am sending all 50 chars to try to save some consistency between the 2 sketches. this way I know that I always need to read 50 chars and I dont need to send a msg head...

for some odd reason it started to work and the message is now going across the softSerial. I think what might have happened as Paul S commented on commenting out the x10. This gave me the idea to connect the x10 transceiver up to the wall outlet. Whet i didn''t know was that the x10 transceiver needed to be connected in order to actually execute the lib code. I thought there was a timeout associated with the x10 lib. At the time of posting this I did not have x10 transceiver powered up. I had the cables in place, but the x10 transceiver was not plugged in. Therefore the command in the setup was never being executed and was halting the sketch.

Also. Paul S... do you think I should only send up to the NULL terminator in the sBuffer to the other arduino? It would make the code a little bit more robust. This being stated... is there some type of malloc that I could use to dynamically handle the char array. or should I just make my buffers on the first Arduino larger?

As far as sending the whole array, there are a couple of ways to deal with that. You could send the length first, then the valid data. Less data is transmitted this way, which makes the process faster. The only potential issue with this is that serial data transmission is not guaranteed, so the number of characters actually received will not necessarily the number sent.

The other way is to not worry about the length. Start and end the packet sent with some markers. Read and store the data starting when the start marker arrives, and ending when the end marker arrives. Some sample code to read delimited packets:

// We are here either because all pending serial // data has been read OR because an end of // packet marker arrived. Which is it? if(started && ended) { // The end of packet marker arrived. Process the packet

is there some type of malloc that I could use to dynamically handle the char array. or should I just make my buffers on the first Arduino larger?

There are two problems with trying to dynamically allocate data on the first Arduino. The first is that the data is coming from an ethernet connection, and you have no ideal, before the data starts to arrive, how much there is going to be. Even if you did, there is not a lot of memory available on the Arduino, so memory fragmentation is a real problem when dynamic memory allocation occurs. There is no easy way to rearrange the dynamically allocated memory, to reclaim small fragments.