W850io endPacket() failure

Status
Not open for further replies.

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:

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
 
should I need to call Ethernet.init(15) to reserve CS pin?

I can answer this question: Yes, you definitely need Ethernet.init(15) before Ethernet.begin() if using any pin for CS other than pin 10.


Regarding the rest, I do not know. But I can tell you I only investigate problems with a complete program I can copy into Arduino and run on a real board is posted. If Ethernet.init(15) does not fully solve your problem, maybe you could try creating a small program which shows the problem to share on this forum?

Together with a program to copy into Arduino and upload to a Teensy 3.6, I will also need a clear way to implement the other side of the communication, to recreate the same problem.
 
I can answer this question: Yes, you definitely need Ethernet.init(15) before Ethernet.begin() if using any pin for CS other than pin 10.


Regarding the rest, I do not know. But I can tell you I only investigate problems with a complete program I can copy into Arduino and run on a real board is posted. If Ethernet.init(15) does not fully solve your problem, maybe you could try creating a small program which shows the problem to share on this forum?

Together with a program to copy into Arduino and upload to a Teensy 3.6, I will also need a clear way to implement the other side of the communication, to recreate the same problem.

Yes I will post a full sketch to show the issue but it will take some time and I'm in a hurry. Hope Ethernet.init(15) fixes this.
 
Status
Not open for further replies.
Back
Top