then calculate bit, i.e number of 0 and 1 recived,
store bit count and binary value in different variables.
Below code is mix of code I got through google search.
if (client) {
unsigned char digitdata[15] ;
// TextFinder finder(client);
while (client.connected()) {
if (client.available()) {
char c = client.read(); //gets byte from ethernet buffer
if (c != '\n' && c != '\r' ) {
clientline[index] = c;
index++;
continue;
clientline[index] = 0;
}
if (strstr(clientline, "/WIEG=") != 0) {
char * pch;
char *filename;
pch=strrchr(clientline,'WIEG=');
if (pch!=NULL) {
Serial.println(pch+1);
}
}
delay(1);
client2.stop();
}
}
}
[\code]
output of this code is 0101010101 HTTP/1.1
Check number of bit received, it received between 10 bit to 15 bit.
Need to save binary value in digitdata[15]
Which 0 or 1? That URL does NOT contain only 0 or 1.
It contains a string that contains only 0s and 1s, but that is not the same thing. At all.
After you store the whole URL, in a char array, locating the = sign is trivial. Once you know where that is, the number of bits is trivial to calculate. You know how many characters you stored. You know how many are not in the value part of the URL. The difference is the number of characters that ARE in the value part.
As for making a binary value from the value portion, you have NOT explained whether the bit pattern represents the high bits of the value or the low bits. If you know that, then comparing the chars in the array, and using bitSet() will easily allow you to populate a variable with the "binary string" that you inefficiently send.
PaulS:
Which 0 or 1? That URL does NOT contain only 0 or 1.
It contains a string that contains only 0s and 1s, but that is not the same thing. At all.
After you store the whole URL, in a char array, locating the = sign is trivial. Once you know where that is, the number of bits is trivial to calculate. You know how many characters you stored. You know how many are not in the value part of the URL. The difference is the number of characters that ARE in the value part.
As for making a binary value from the value portion, you have NOT explained whether the bit pattern represents the high bits of the value or the low bits. If you know that, then comparing the chars in the array, and using bitSet() will easily allow you to populate a variable with the "binary string" that you inefficiently send.
yes URL contins characters, as 0 and 1, and other html code.
Yes, 1 represents high, and 0 represents low. below is code for another program which reads from serial port.
I am not able to figure out how to store only 0 and 1 , between DIGIT= and HTML
if ( incomingByte == '0' ){ // No useless comment needed
Which do you prefer?
How is databits defined? Initialized? Why are you not storing the 0s too?
How do YOU think reading data from the serial port differs from reading it from a client instance? The correct answer is that it does not differ AT ALL.
PaulS:
How do YOU think reading data from the serial port differs from reading it from a client instance? The correct answer is that it does not differ AT ALL.
Serial port: I am able to send only 0 and 1 , no additional data.
Ethernet: Web page is sending data, it has html contents, so storing as character.
I am new to CPP / Arduino programing, I see example codes, documentations and then use part of code required.