Error compiling at the command client.write
Posted: Fri Jan 08, 2016 11:40 am
In a part of my code i am using the following command
The above code is a part of a code that i am developing for communicating with a TCP server over port 40000.
The arduino IDE shows en error compiling message possibly due to the <code>client.write()</code> statement. However the function is described as having two possible arguments- the buffer ie the array and the size of the array. I have to use <code>client.write()</code> because i need to send 7 bytes in HEX. in order to avoid this kind of an error, i had converted my ns[] into a char type array and used client.print() instead ,but i'm afraid i can'y do the same this time.
The error shown is:
In file included from C:\Users\Piyush\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\ESP8266WiFi\src/ESP8266WiFi.h:32:0,
from ESP_Wifi.ino:3:
C:\Users\Piyush\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\ESP8266WiFi\src/WiFiClient.h: In instantiation of 'size_t WiFiClient::write(T&) [with T = unsigned char [7]; size_t = unsigned int]':
ESP_Wifi.ino:85:27: required from here
C:\Users\Piyush\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\ESP8266WiFi\src/WiFiClient.h:78:28: error: request for member 'available' in 'src', which is of non-class type 'unsigned char [7]'
while (src.available() > WIFICLIENT_MAX_PACKET_SIZE){
^
C:\Users\Piyush\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\ESP8266WiFi\src/WiFiClient.h:79:7: error: request for member 'read' in 'src', which is of non-class type 'unsigned char [7]'
src.read(obuf, WIFICLIENT_MAX_PACKET_SIZE);
^
C:\Users\Piyush\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\ESP8266WiFi\src/WiFiClient.h:87:38: error: request for member 'available' in 'src', which is of non-class type 'unsigned char [7]'
uint16_t leftLen = src.available();
^
C:\Users\Piyush\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\ESP8266WiFi\src/WiFiClient.h:88:5: error: request for member 'read' in 'src', which is of non-class type 'unsigned char [7]'
src.read(obuf, leftLen);
^
Error compiling.
Also if there is any other way of sending 6-7 HEX bytes at once to the ESP or to the client please mention.
Code: Select all
byte Debug[7] = {0xAB, 0x0D, 0x30, 0x01, 0x33, 0x00, 0x00};
//Debug[6] is the main debug packet
byte message = 0x00; // this variable will be for the last byte of Debug array
double timeout=300000;
double CurrentTime,LastTime;
while (client.connected())//See if client is connected to server
{
//******************************************
//**SEND DATA TO SERVER
while (Serial.available())
{
LastTime = millis();
if (message & 0x80)
{
Serial.println("DATA Received..clearing the error");
message = 0x00;
Debug[6] = message;
client.write(Debug, sizeof(Debug));
Serial.write(Debug, sizeof(Debug));
}
for (i = 0; i < 7; i++)
{
ns[i] = Serial.read();
if (ns[i] != -1)
{
delay(100);
}
}
client.print(ns);
Serial.println(ns);
}
//after all the data that was in the serial buffer is sent, check if there is anythng that the server responds
//*************************************************
// DEBUG MESSAGE FORMATION
CurrentTime = millis();
if (CurrentTime - LastTime >= timeout)
{
// No data received from Receiver in last 5 minutes
//change bit number 3 ie 4th bit from the right.
message |= 0x08;
Debug[6] = message;
Serial.println("Sending Debug Message: No data for 5 min");
client.write(Debug, sizeof(Debug));
Serial.write(Debug, sizeof(Debug));
}
}
The above code is a part of a code that i am developing for communicating with a TCP server over port 40000.
The arduino IDE shows en error compiling message possibly due to the <code>client.write()</code> statement. However the function is described as having two possible arguments- the buffer ie the array and the size of the array. I have to use <code>client.write()</code> because i need to send 7 bytes in HEX. in order to avoid this kind of an error, i had converted my ns[] into a char type array and used client.print() instead ,but i'm afraid i can'y do the same this time.
The error shown is:
In file included from C:\Users\Piyush\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\ESP8266WiFi\src/ESP8266WiFi.h:32:0,
from ESP_Wifi.ino:3:
C:\Users\Piyush\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\ESP8266WiFi\src/WiFiClient.h: In instantiation of 'size_t WiFiClient::write(T&) [with T = unsigned char [7]; size_t = unsigned int]':
ESP_Wifi.ino:85:27: required from here
C:\Users\Piyush\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\ESP8266WiFi\src/WiFiClient.h:78:28: error: request for member 'available' in 'src', which is of non-class type 'unsigned char [7]'
while (src.available() > WIFICLIENT_MAX_PACKET_SIZE){
^
C:\Users\Piyush\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\ESP8266WiFi\src/WiFiClient.h:79:7: error: request for member 'read' in 'src', which is of non-class type 'unsigned char [7]'
src.read(obuf, WIFICLIENT_MAX_PACKET_SIZE);
^
C:\Users\Piyush\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\ESP8266WiFi\src/WiFiClient.h:87:38: error: request for member 'available' in 'src', which is of non-class type 'unsigned char [7]'
uint16_t leftLen = src.available();
^
C:\Users\Piyush\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\ESP8266WiFi\src/WiFiClient.h:88:5: error: request for member 'read' in 'src', which is of non-class type 'unsigned char [7]'
src.read(obuf, leftLen);
^
Error compiling.
Also if there is any other way of sending 6-7 HEX bytes at once to the ESP or to the client please mention.