guys
i know it is a totally stupid question... but i'm stuck here...
void bmsCommunication() {
// wait for a new client:
EthernetClient client = server.available();
memset(socketString, 0, sizeof(socketString));
// when the client sends the first byte, say hello:
if (client) {
if (!alreadyConnected) {
// clear out the input buffer:
client.flush();
DEBUG_PRINT(F("New Session Estublished!"));
//Serial.println(client.remoteIP());
client.write("ACK");
alreadyConnected = true;
}
// Read a line at a time
memset(socketString, 0, sizeof(socketString)); // Clear contents of Buffer
boolean lineEnd = false;
while (!lineEnd) {
while (client.available() > 0) {
char c = client.read();
if (c != '\n' && c != '\r') {
strcat(socketString, c);
//socketString.concat(c);
}
if (c == '\n') {
lineEnd = true;
client.flush();
}
}
}
DEBUG_PRINT("Remote said:");
DEBUG_PRINTLN(socketString);
if (strcmp(socketString, "ping") == 0) {
//if (socketString == "ping") {
server.print(F("<"));
for(int i=0; i<10; i++){
server.print(sbcStrRS232_tx[i], DEC);
//Serial.print(F(";"));
}
server.println(F(">"));
//server.print(outputReport());
DEBUG_PRINT("I said:");
DEBUG_PRINTLN(outputReport());
}
}
}
this is the function i am trying to use... earlier this was made of String and a perfect usable one... now I have converted the socketString in to a char. hence i need to read the data from ethernet to this, so that I can then do analysis.
Also The part after ping, I'm actually confused. All I need there is to send a <1000000> type data, where the data will be generated from a bunch of char data in another function and then it needs to be a single data[] and then needs to be sent to a vb.net socket program. ideas??
// Read a line at a time
memset(socketString, 0, sizeof(socketString)); // Clear contents of Buffer
boolean lineEnd = false;
while (!lineEnd) {
while (client.available() > 0) {
char c = client.read();
if (c != '\n' && c != '\r') {
strcat(socketString, c);
//socketString.concat(c);
}
you also seem to have nothing preventing you from writing past the end of the socketString array.
here it needs to read and put the things in a char array [say char readStream[13] ] and that should be until a VBCRLF found (means \n). Once I can do that, using char (not string as I found like others, string is the thing to be avoided), then I can read the command "ping" and then can send the "pong".
Now, the pong is basically a bunch of chars again, data[0] till data [10] and that needs to be made as data[] = <10000000>
This I can do using serial, but can't do using ethernet and morely, i need to send a single string, not a stream... [since it is ethernet, not serial where i cound do "until \n" ]
Sorrry, can you help me by writing this in a whole?? I've been working for last 48hr in a vb.net with struggling in serial read and then switching to ethernet to solve a pathetic issue. and head is blocked... time is running short...
OKey~~~ So I am an idiot... a stupid!! I was spending the whole night on coding and then in the morning my wife discovered that the arduino shield's RJ45 was not connected and I'm struggling with the code...
Anyway, that function i hope works... (should be, logically, dont see any reason for NOT)
Now comes the second part... I need to construct the final array as <100110110> type something. my code can do it for Serial output. But for ethernet, i need it... and that should give a single throw shot... I'm attaching my codes here... So you guys will be able to get it...