weirdgyn
Member
I'm writing a quite complex sketch where I use Ethernet library to provide UDP bidirectional connections between a Teensy 3.6 + W850io module and a client application running on an Android tablet.
The 'receving' part (running on Teensy) works fine but when I try to send data back to the client I got a very strange behaviour on endPacket(): everything stops working just after this call..
This's the function where I send data over UDP connection:
The code after endPacket() call is never executed. Of course DEBUG_SEND_TELEMETRY is defined.
I connected the W850io module to the default SPI0 bus i.e. pin 11 (mosi0), 12 (miso0), 13 (sck0), 15 (cs0).
I have not other SPI units connected on such bus ... should I need to call Ethernet.init(15) to reserve CS pin?
Best regards,
Michele Santucci
The 'receving' part (running on Teensy) works fine but when I try to send data back to the client I got a very strange behaviour on endPacket(): everything stops working just after this call..
This's the function where I send data over UDP connection:
Code:
void sendTelemetry(int i, const char* _identification, int _value)
{
char _buffer[5] = { 0, 0, 0, 0, 0 };
char _buffer_crc[3] = { 0, 0, 0 };
char _buffer_identification[2] = { 0, 0 };
String _aux = "";
byte _crc = 0x00;
_aux.reserve(16);
Int2HexStr(_value, _buffer);
_crc = computeCRC(_buffer); // TODO: calcolo crc
Byte2HexStr(_crc, _buffer_crc); // sprint(_buffer_crc,"%02X", _crc );
#ifdef DEBUG_SEND_TELEMETRY
Serial.print("CRC(0x)=");
Serial.println(_buffer_crc);
#endif
sprintf(_buffer_identification, "%d", i);
_aux = "$";
_aux += _identification;
_aux += _buffer_identification;
_aux += _buffer;
_aux += _buffer_crc;
_aux += "&";
if (ethTelemetry.beginPacket(destinationIP, UDP_REMOTE_PORT) == 1)
{
ethTelemetry.write(_aux.c_str());
#ifdef DEBUG_SEND_TELEMETRY
Serial.print("UDP sending: ");
#endif
if (ethTelemetry.endPacket() != 1)
{
#ifdef DEBUG_SEND_TELEMETRY
Serial.print("endPacket() failed!");
#endif
}
}
else
{
#ifdef DEBUG_SEND_TELEMETRY
Serial.print("beginPacket() failed!");
#endif
}
#ifdef DEBUG_SEND_TELEMETRY
Serial.print("...sent: ");
Serial.println(_aux.c_str());
#endif
}
The code after endPacket() call is never executed. Of course DEBUG_SEND_TELEMETRY is defined.
I connected the W850io module to the default SPI0 bus i.e. pin 11 (mosi0), 12 (miso0), 13 (sck0), 15 (cs0).
I have not other SPI units connected on such bus ... should I need to call Ethernet.init(15) to reserve CS pin?
Best regards,
Michele Santucci