for(i = 0; i < MAX_SRV_CLIENTS; i++) {
if (serverClients[i] && serverClients[i].connected()) {
if(serverClients[i].available()) {
- //get data from the telnet client and push it to the UART
-// while(serverClients[i].available()) Serial.write(serverClients[i].read());
//get data from the telnet client and push it to I2C
- while(serverClients[i].available()) {getstring = serverClients[i].read(); //<------ Hier ist der Fehler mit getstring
- Serial.print("\nGETDATASTRING: "); Serial.print(getstring);
+ while(serverClients[i].available()) {getstring = char(serverClients[i].read());
for(uint8_t m=0; m < getstring.length(); m++){
getdata(getstring.charAt(m));
}
size_t len = sbuf.length();
uint8_t buf[len];
- sbuf.toCharArray((char*)buf, len);
+ sbuf.toCharArray((char*)buf, len); // Copies the String’s characters to the supplied buffer.
counter += 1;
if (counter == 1) {
//write
if (rxbuf[0] == 'W'){
- Serial.print("WRITECHECK");
//ADCsettings
if (hex_to_int(rxbuf[5]) == 9) {
// uint8_t val = (hex_to_int(rxbuf[7])*16+hex_to_int(rxbuf[8]))&0xFF;
send_answer_hex(&rxbuf[0], new_gain);
}
+ }
//read
if (rxbuf[0] == 'R'){
- Serial.print("READCHECK");
-
+ //read single ADC Channel
if (hex_to_int(rxbuf[5]) == 10) {
- //read single ADC Channel
- uint8_t adc_val = 0xFFFF;
+ uint16_t adc_val = 0xFFFF;
//CH0
- if (hex_to_int(rxbuf[4]) == 0) {adc_val=fadc0;
+ if (hex_to_int(rxbuf[4]) == 0) {adc_val=fadc0*16;
}
//CH1
- if (hex_to_int(rxbuf[4]) == 1) {adc_val=fadc1;
+ if (hex_to_int(rxbuf[4]) == 1) {adc_val=fadc1*16;
}
//CH2
- if (hex_to_int(rxbuf[4]) == 2) {adc_val=fadc2;
+ if (hex_to_int(rxbuf[4]) == 2) {adc_val=fadc2*16;
}
//CH3
- if (hex_to_int(rxbuf[4]) == 3) {adc_val=fadc3;
+ if (hex_to_int(rxbuf[4]) == 3) {adc_val=fadc3*16;
}
send_answer_hex(&rxbuf[0], adc_val);
}
}
}
+ if (rxcnt >= 10 || buf == '\n' || buf == '\r') { rxcnt = 0; }
}
}
-}