You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
4.9 KiB

​
​
4 months ago
​
Ethernet2UART gateway: fix the reconnect loop, leaked connections and ping check From the la_mojo log of a gateway reached over the Internet (2.54.237.28:8234): deviceETH2UART - In TCP mode, link health is the TCP connection itself (socket, I/O thread, SO_ERROR, TCP keepalive). ICMP isn't used there: gateways on mobile networks often don't answer ping, and the working connection was closed every second ("No Ping to device!"). - Ping (UDP modes) up to 3 echoes x 2000 ms, at most every 10 s. Only an echo reply from the gateway with our id and sequence counts. A signal (EINTR) no longer ends the wait. The old single recvfrom() with SO_RCVTIMEO returned EINTR at the first signal, even with SA_RESTART. - TCP connect timeout 1 s -> 5 s (E2UART_CONNECT_TIMEOUT_MS), and EINTR in select() continues waiting. - create_SOL() closes the previous socket and I/O thread first. It overwrote the socket (the connection leaked) and init() failed while the old thread ran, so each reconnect left an open TCP connection at the gateway and the node stayed invalid although "Connected". If init() fails, the new socket is closed. - create()/validate()/reconnect() are serialised: they run on the node factory thread and on the hardware manager thread. - Registered with the hardware manager once. Re-creation from the hardware manager locked its non-recursive list mutex again (deadlock). - Reconnect back-off 2 s -> 30 s. - recv() == 0 on TCP means the gateway closed the connection (a stale errno was checked before). - Destructor resigns from the hardware manager before closing. deviceNodeFactory - deleteNode() deletes the gateway object. It was only removed from the list and kept running next to the new node created for the same id. - Nodes are deleted after the validation loop (erasing inside it skipped the next node). deviceNode::validate - Compares the configuration only. "online" changes whenever another object of the same node id is created or deleted. hardwareManager::assignResource - Ignores a resource that is already assigned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1 day ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
Ethernet2UART gateway: wait long enough for the device's reply over the Internet "NODSEN: Communication Wait State TO!" with a sensor behind the gateway: in SERIAL_PING_PONG mode the I/O thread waited only 20 x 5 ms (~100 ms, a serial-line value) for the reply to a request, and did not read the socket while no request was queued. A reply slower than that, which is normal over a mobile link, stayed in the socket. It was read with the next request and given to that request's parser, so the sensor ran one reply behind, retried, and after 16 failed attempts reported the timeout. deviceETH2UART I/O thread (SERIAL_PING_PONG) - Waits up to E2UART_REPLY_TIMEOUT_MS (800 ms, below the sensor's 1 s per attempt) for the reply to start, and E2UART_REPLY_GAP_MS (150 ms) between the pieces of a reply split over several TCP segments. It is done as soon as the parser has a complete packet and no more data is waiting (as before). - Reads the socket also between requests. Late data goes to the parser of the last request at once. - Gives data only to a parser that is still bound to the transport (a sensor that disconnected or was deleted is no longer called). Serial resource casts (deviceNode2D, deviceNodeCamera) - dynamic_cast<basicTransport*> instead of static_cast through hardwareResourceSerialProvider. The resource can be a deviceETH2UART, and the old cast was only right because of a matching base-class layout. A NULL transport isn't bound. Tested with a fake device answering after 50/300/700 ms, also split into two TCP pieces. The old code delivered nothing, or the previous request's answer. Now each request gets its own answer (ASan clean). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
15 hours ago
​
​
​
Ethernet2UART gateway: wait long enough for the device's reply over the Internet "NODSEN: Communication Wait State TO!" with a sensor behind the gateway: in SERIAL_PING_PONG mode the I/O thread waited only 20 x 5 ms (~100 ms, a serial-line value) for the reply to a request, and did not read the socket while no request was queued. A reply slower than that, which is normal over a mobile link, stayed in the socket. It was read with the next request and given to that request's parser, so the sensor ran one reply behind, retried, and after 16 failed attempts reported the timeout. deviceETH2UART I/O thread (SERIAL_PING_PONG) - Waits up to E2UART_REPLY_TIMEOUT_MS (800 ms, below the sensor's 1 s per attempt) for the reply to start, and E2UART_REPLY_GAP_MS (150 ms) between the pieces of a reply split over several TCP segments. It is done as soon as the parser has a complete packet and no more data is waiting (as before). - Reads the socket also between requests. Late data goes to the parser of the last request at once. - Gives data only to a parser that is still bound to the transport (a sensor that disconnected or was deleted is no longer called). Serial resource casts (deviceNode2D, deviceNodeCamera) - dynamic_cast<basicTransport*> instead of static_cast through hardwareResourceSerialProvider. The resource can be a deviceETH2UART, and the old cast was only right because of a matching base-class layout. A NULL transport isn't bound. Tested with a fake device answering after 50/300/700 ms, also split into two TCP pieces. The old code delivered nothing, or the previous request's answer. Now each request gets its own answer (ASan clean). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
15 hours ago
​
​
​
Ethernet2UART gateway: fix the reconnect loop, leaked connections and ping check From the la_mojo log of a gateway reached over the Internet (2.54.237.28:8234): deviceETH2UART - In TCP mode, link health is the TCP connection itself (socket, I/O thread, SO_ERROR, TCP keepalive). ICMP isn't used there: gateways on mobile networks often don't answer ping, and the working connection was closed every second ("No Ping to device!"). - Ping (UDP modes) up to 3 echoes x 2000 ms, at most every 10 s. Only an echo reply from the gateway with our id and sequence counts. A signal (EINTR) no longer ends the wait. The old single recvfrom() with SO_RCVTIMEO returned EINTR at the first signal, even with SA_RESTART. - TCP connect timeout 1 s -> 5 s (E2UART_CONNECT_TIMEOUT_MS), and EINTR in select() continues waiting. - create_SOL() closes the previous socket and I/O thread first. It overwrote the socket (the connection leaked) and init() failed while the old thread ran, so each reconnect left an open TCP connection at the gateway and the node stayed invalid although "Connected". If init() fails, the new socket is closed. - create()/validate()/reconnect() are serialised: they run on the node factory thread and on the hardware manager thread. - Registered with the hardware manager once. Re-creation from the hardware manager locked its non-recursive list mutex again (deadlock). - Reconnect back-off 2 s -> 30 s. - recv() == 0 on TCP means the gateway closed the connection (a stale errno was checked before). - Destructor resigns from the hardware manager before closing. deviceNodeFactory - deleteNode() deletes the gateway object. It was only removed from the list and kept running next to the new node created for the same id. - Nodes are deleted after the validation loop (erasing inside it skipped the next node). deviceNode::validate - Compares the configuration only. "online" changes whenever another object of the same node id is created or deleted. hardwareManager::assignResource - Ignores a resource that is already assigned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1 day ago
​
​
​
​
​
​
Ethernet2UART gateway: reconnect when the device goes silent on a live connection Field log (sensor behind 2.54.237.28:8234): normal replies avg 129 ms, spikes up to 2.6 s handled. Then no reply at all to 19 requests in a row while the TCP connection stayed "up" (sending never failed). The sensor failed after 17 attempts and kept using the dead connection. A dead mobile/NAT path isn't reported by the kernel for many minutes, and keepalive only probes idle connections. - TCP_USER_TIMEOUT 10 s (E2UART_TCP_USER_TIMEOUT_MS): sent data not acknowledged by the gateway drops the connection. - After 5 requests in a row (E2UART_NO_REPLY_RECONNECT) without a single reply byte, the I/O thread ends ("No reply to 5 requests in a row - reconnecting to the gateway"). validate() sees the lost link and opens a new connection. Late data resets the count. - closePort() frees the requests still queued for the closed connection. - "NO reply" log lines (DEBUG_COMMUNICATION) and the reconnect error show TCP_INFO: unacked data, retransmits, rtt, last ACK / last data received. Unacked data and an old last ACK mean the network path is dead; ACKs that keep coming mean the gateway/device side doesn't answer. Tested with a fake device that goes silent after 3 replies while keeping the TCP connection open: the reconnect came after the 5th unanswered request, and requests 9-12 were answered on the new connection (ASan clean). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
14 hours ago
​
​
​
​
​
​
​
​
​
​
Ethernet2UART gateway: reconnect when the device goes silent on a live connection Field log (sensor behind 2.54.237.28:8234): normal replies avg 129 ms, spikes up to 2.6 s handled. Then no reply at all to 19 requests in a row while the TCP connection stayed "up" (sending never failed). The sensor failed after 17 attempts and kept using the dead connection. A dead mobile/NAT path isn't reported by the kernel for many minutes, and keepalive only probes idle connections. - TCP_USER_TIMEOUT 10 s (E2UART_TCP_USER_TIMEOUT_MS): sent data not acknowledged by the gateway drops the connection. - After 5 requests in a row (E2UART_NO_REPLY_RECONNECT) without a single reply byte, the I/O thread ends ("No reply to 5 requests in a row - reconnecting to the gateway"). validate() sees the lost link and opens a new connection. Late data resets the count. - closePort() frees the requests still queued for the closed connection. - "NO reply" log lines (DEBUG_COMMUNICATION) and the reconnect error show TCP_INFO: unacked data, retransmits, rtt, last ACK / last data received. Unacked data and an old last ACK mean the network path is dead; ACKs that keep coming mean the gateway/device side doesn't answer. Tested with a fake device that goes silent after 3 replies while keeping the TCP connection open: the reconnect came after the 5th unanswered request, and requests 9-12 were answered on the new connection (ASan clean). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
14 hours ago
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
Ethernet2UART gateway: fix the reconnect loop, leaked connections and ping check From the la_mojo log of a gateway reached over the Internet (2.54.237.28:8234): deviceETH2UART - In TCP mode, link health is the TCP connection itself (socket, I/O thread, SO_ERROR, TCP keepalive). ICMP isn't used there: gateways on mobile networks often don't answer ping, and the working connection was closed every second ("No Ping to device!"). - Ping (UDP modes) up to 3 echoes x 2000 ms, at most every 10 s. Only an echo reply from the gateway with our id and sequence counts. A signal (EINTR) no longer ends the wait. The old single recvfrom() with SO_RCVTIMEO returned EINTR at the first signal, even with SA_RESTART. - TCP connect timeout 1 s -> 5 s (E2UART_CONNECT_TIMEOUT_MS), and EINTR in select() continues waiting. - create_SOL() closes the previous socket and I/O thread first. It overwrote the socket (the connection leaked) and init() failed while the old thread ran, so each reconnect left an open TCP connection at the gateway and the node stayed invalid although "Connected". If init() fails, the new socket is closed. - create()/validate()/reconnect() are serialised: they run on the node factory thread and on the hardware manager thread. - Registered with the hardware manager once. Re-creation from the hardware manager locked its non-recursive list mutex again (deadlock). - Reconnect back-off 2 s -> 30 s. - recv() == 0 on TCP means the gateway closed the connection (a stale errno was checked before). - Destructor resigns from the hardware manager before closing. deviceNodeFactory - deleteNode() deletes the gateway object. It was only removed from the list and kept running next to the new node created for the same id. - Nodes are deleted after the validation loop (erasing inside it skipped the next node). deviceNode::validate - Compares the configuration only. "online" changes whenever another object of the same node id is created or deleted. hardwareManager::assignResource - Ignores a resource that is already assigned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1 day ago
​
​
​
Ethernet2UART gateway: fix the reconnect loop, leaked connections and ping check From the la_mojo log of a gateway reached over the Internet (2.54.237.28:8234): deviceETH2UART - In TCP mode, link health is the TCP connection itself (socket, I/O thread, SO_ERROR, TCP keepalive). ICMP isn't used there: gateways on mobile networks often don't answer ping, and the working connection was closed every second ("No Ping to device!"). - Ping (UDP modes) up to 3 echoes x 2000 ms, at most every 10 s. Only an echo reply from the gateway with our id and sequence counts. A signal (EINTR) no longer ends the wait. The old single recvfrom() with SO_RCVTIMEO returned EINTR at the first signal, even with SA_RESTART. - TCP connect timeout 1 s -> 5 s (E2UART_CONNECT_TIMEOUT_MS), and EINTR in select() continues waiting. - create_SOL() closes the previous socket and I/O thread first. It overwrote the socket (the connection leaked) and init() failed while the old thread ran, so each reconnect left an open TCP connection at the gateway and the node stayed invalid although "Connected". If init() fails, the new socket is closed. - create()/validate()/reconnect() are serialised: they run on the node factory thread and on the hardware manager thread. - Registered with the hardware manager once. Re-creation from the hardware manager locked its non-recursive list mutex again (deadlock). - Reconnect back-off 2 s -> 30 s. - recv() == 0 on TCP means the gateway closed the connection (a stale errno was checked before). - Destructor resigns from the hardware manager before closing. deviceNodeFactory - deleteNode() deletes the gateway object. It was only removed from the list and kept running next to the new node created for the same id. - Nodes are deleted after the validation loop (erasing inside it skipped the next node). deviceNode::validate - Compares the configuration only. "online" changes whenever another object of the same node id is created or deleted. hardwareManager::assignResource - Ignores a resource that is already assigned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1 day ago
​
​
​
​
Ethernet2UART gateway: fix the reconnect loop, leaked connections and ping check From the la_mojo log of a gateway reached over the Internet (2.54.237.28:8234): deviceETH2UART - In TCP mode, link health is the TCP connection itself (socket, I/O thread, SO_ERROR, TCP keepalive). ICMP isn't used there: gateways on mobile networks often don't answer ping, and the working connection was closed every second ("No Ping to device!"). - Ping (UDP modes) up to 3 echoes x 2000 ms, at most every 10 s. Only an echo reply from the gateway with our id and sequence counts. A signal (EINTR) no longer ends the wait. The old single recvfrom() with SO_RCVTIMEO returned EINTR at the first signal, even with SA_RESTART. - TCP connect timeout 1 s -> 5 s (E2UART_CONNECT_TIMEOUT_MS), and EINTR in select() continues waiting. - create_SOL() closes the previous socket and I/O thread first. It overwrote the socket (the connection leaked) and init() failed while the old thread ran, so each reconnect left an open TCP connection at the gateway and the node stayed invalid although "Connected". If init() fails, the new socket is closed. - create()/validate()/reconnect() are serialised: they run on the node factory thread and on the hardware manager thread. - Registered with the hardware manager once. Re-creation from the hardware manager locked its non-recursive list mutex again (deadlock). - Reconnect back-off 2 s -> 30 s. - recv() == 0 on TCP means the gateway closed the connection (a stale errno was checked before). - Destructor resigns from the hardware manager before closing. deviceNodeFactory - deleteNode() deletes the gateway object. It was only removed from the list and kept running next to the new node created for the same id. - Nodes are deleted after the validation loop (erasing inside it skipped the next node). deviceNode::validate - Compares the configuration only. "online" changes whenever another object of the same node id is created or deleted. hardwareManager::assignResource - Ignores a resource that is already assigned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1 day ago
​
​
​
​
​
​
​
4 months ago
​
​
Ethernet2UART gateway: wait long enough for the device's reply over the Internet "NODSEN: Communication Wait State TO!" with a sensor behind the gateway: in SERIAL_PING_PONG mode the I/O thread waited only 20 x 5 ms (~100 ms, a serial-line value) for the reply to a request, and did not read the socket while no request was queued. A reply slower than that, which is normal over a mobile link, stayed in the socket. It was read with the next request and given to that request's parser, so the sensor ran one reply behind, retried, and after 16 failed attempts reported the timeout. deviceETH2UART I/O thread (SERIAL_PING_PONG) - Waits up to E2UART_REPLY_TIMEOUT_MS (800 ms, below the sensor's 1 s per attempt) for the reply to start, and E2UART_REPLY_GAP_MS (150 ms) between the pieces of a reply split over several TCP segments. It is done as soon as the parser has a complete packet and no more data is waiting (as before). - Reads the socket also between requests. Late data goes to the parser of the last request at once. - Gives data only to a parser that is still bound to the transport (a sensor that disconnected or was deleted is no longer called). Serial resource casts (deviceNode2D, deviceNodeCamera) - dynamic_cast<basicTransport*> instead of static_cast through hardwareResourceSerialProvider. The resource can be a deviceETH2UART, and the old cast was only right because of a matching base-class layout. A NULL transport isn't bound. Tested with a fake device answering after 50/300/700 ms, also split into two TCP pieces. The old code delivered nothing, or the previous request's answer. Now each request gets its own answer (ASan clean). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
15 hours ago
​
Ethernet2UART gateway: reconnect when the device goes silent on a live connection Field log (sensor behind 2.54.237.28:8234): normal replies avg 129 ms, spikes up to 2.6 s handled. Then no reply at all to 19 requests in a row while the TCP connection stayed "up" (sending never failed). The sensor failed after 17 attempts and kept using the dead connection. A dead mobile/NAT path isn't reported by the kernel for many minutes, and keepalive only probes idle connections. - TCP_USER_TIMEOUT 10 s (E2UART_TCP_USER_TIMEOUT_MS): sent data not acknowledged by the gateway drops the connection. - After 5 requests in a row (E2UART_NO_REPLY_RECONNECT) without a single reply byte, the I/O thread ends ("No reply to 5 requests in a row - reconnecting to the gateway"). validate() sees the lost link and opens a new connection. Late data resets the count. - closePort() frees the requests still queued for the closed connection. - "NO reply" log lines (DEBUG_COMMUNICATION) and the reconnect error show TCP_INFO: unacked data, retransmits, rtt, last ACK / last data received. Unacked data and an old last ACK mean the network path is dead; ACKs that keep coming mean the gateway/device side doesn't answer. Tested with a fake device that goes silent after 3 replies while keeping the TCP connection open: the reconnect came after the 5th unanswered request, and requests 9-12 were answered on the new connection (ASan clean). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
14 hours ago
4 months ago
​
​
​
​
4 months ago
​
​
​
​
4 months ago
​
​
4 months ago
​
​
​
​
​
  1. #ifndef __DEVICE_NODE_ETHERNET2SERIAL_HEADER__
  2. #define __DEVICE_NODE_ETHERNET2SERIAL_HEADER__
  3. #include "../../data/transport/transportSocket.h"
  4. //#include "../components/base/basicTransport.h"
  5. #include "deviceNode.h"
  6. #include "hardwareResource.h"
  7. #include <mutex>
  8. // Timeouts for a gateway reached over the Internet (the 1 s connect timeout was a LAN value)
  9. #ifndef E2UART_CONNECT_TIMEOUT_MS
  10. #define E2UART_CONNECT_TIMEOUT_MS 5000 // TCP connect
  11. #endif
  12. #ifndef E2UART_PING_TIMEOUT_MS
  13. #define E2UART_PING_TIMEOUT_MS 2000 // wait for one ICMP echo reply
  14. #endif
  15. #ifndef E2UART_PING_ATTEMPTS
  16. #define E2UART_PING_ATTEMPTS 3 // echo requests before the device counts as unreachable
  17. #endif
  18. #ifndef E2UART_PING_INTERVAL_MS
  19. #define E2UART_PING_INTERVAL_MS 10000 // UDP modes: ping at most this often (validate() runs every second)
  20. #endif
  21. // Reply of the device to one request (SERIAL_PING_PONG I/O thread). The 20 x 5 ms (~100 ms) of the
  22. // serial line were too short over the Internet: a later reply was read only with the NEXT request
  23. // and given to that request's parser (one reply behind -> retries -> "Communication Wait State TO!")
  24. #ifndef E2UART_REPLY_TIMEOUT_MS
  25. #define E2UART_REPLY_TIMEOUT_MS 2500 // first byte of the reply (below the sensor's LGS_NETWORK_TO_COUNTER, 3 s)
  26. #endif
  27. #ifndef E2UART_REPLY_GAP_MS
  28. #define E2UART_REPLY_GAP_MS 150 // a started but incomplete reply: wait this long for the rest
  29. #endif
  30. // Reconnect back-off after a failed connect: 2 s, 4 s, ... up to 30 s
  31. #define E2UART_RECONNECT_MIN_MS 2000
  32. #define E2UART_RECONNECT_MAX_MS 30000
  33. // TCP keepalive: a dead link is detected in about IDLE + INTVL * CNT seconds
  34. #define E2UART_KEEPALIVE_IDLE_S 20
  35. #define E2UART_KEEPALIVE_INTVL_S 5
  36. #define E2UART_KEEPALIVE_CNT 4
  37. // Sent data not acknowledged by the gateway for this long: the kernel drops the connection (a dead
  38. // mobile / NAT path otherwise looks alive for many minutes - keepalive only probes idle connections)
  39. #ifndef E2UART_TCP_USER_TIMEOUT_MS
  40. #define E2UART_TCP_USER_TIMEOUT_MS 10000
  41. #endif
  42. // Requests in a row without any reply byte: reconnect to the gateway (the device went silent while
  43. // the TCP connection stayed up - a new connection resets the gateway session / NAT mapping)
  44. // Requests waiting for the I/O thread (e.g. queries of the sensor during a reconnect): the oldest are
  45. // dropped beyond this (a long outage must not grow the queue without limit)
  46. #ifndef E2UART_MAX_QUEUED
  47. #define E2UART_MAX_QUEUED 16
  48. #endif
  49. #ifndef E2UART_NO_REPLY_RECONNECT
  50. #define E2UART_NO_REPLY_RECONNECT 5
  51. #endif
  52. #ifdef SERIAL_PING_PONG
  53. class deviceETH2UART : public deviceNode, public hardwareResource, public basicTransport, public basicThread
  54. #else
  55. class deviceETH2UART : public deviceNode, public hardwareResource, public basicTransport, public basicDualThread
  56. #endif
  57. {
  58. private:
  59. // basicLogCollection * m_pLog;
  60. DBC_UART_DATA m_sUartData;
  61. int m_iDeviceFD;
  62. int m_iMasterFD;
  63. #ifdef __linux__
  64. int m_iInFID;
  65. int m_iOutFID;
  66. #else
  67. DCB PortDCB;
  68. HANDLE m_ioFID;
  69. #endif
  70. // create() / validate() / reconnect() / closePort() run on the node factory thread AND on the
  71. // hardware manager thread (the class is a deviceNode and a hardwareResource): one at a time
  72. std::recursive_mutex m_mConnLock;
  73. bool m_bRegistered; // assigned to the hardware manager (once)
  74. volatile bool m_bConnecting; // create_SOL() is opening the connection (requests are queued meanwhile)
  75. bool m_bLastPingOk;
  76. uint64_t m_nNextPingMs;
  77. uint64_t m_nNextConnectMs;
  78. uint32_t m_nConnectBackoffMs;
  79. bool pingDevice();
  80. bool pingOnce(int sockfd, uint16_t id, uint16_t seq, char * reason, size_t reasonSize);
  81. bool linkAlive(void);
  82. bool connectSOL(void); // create_SOL() with the reconnect back-off
  83. bool create_SOL();
  84. bool closePort();
  85. int sendBlock(unsigned char * Data, int DataSize);
  86. int recptBlock(unsigned char * Buffer, int * BufferLength);
  87. protected:
  88. #ifdef SERIAL_PING_PONG
  89. virtual void m_fThreadProc(void);
  90. Q_SIO_TZ m_qIO;
  91. protocolParser * m_pLastParser; // parser of the last request: gets data that arrives between requests
  92. bool isRecipient(protocolParser * p); // still bound to this transport (not deleted / detached)
  93. void tcpInfoText(char * buf, size_t size); // unacked data / retransmits / last ACK of the connection
  94. #else
  95. U8 m_pInputBuffer[MAXIMAL_SOCKET_IO_BUFFER_LENGTH];
  96. U8 m_pOutputBuffer[MAXIMAL_SOCKET_IO_BUFFER_LENGTH];
  97. int m_nInputBufferSize;
  98. int m_nOutputBufferSize;
  99. virtual void m_fThreadAProc(void);
  100. virtual void m_fThreadBProc(void);
  101. #endif
  102. public:
  103. explicit deviceETH2UART(uint32_t nodeID);
  104. ~deviceETH2UART();
  105. virtual bool create(void);
  106. virtual bool validate(void);
  107. #ifdef SERIAL_PING_PONG
  108. virtual bool sendData(uint8_t * Data, int DataSize, protocolParser *src = NULL );
  109. #else
  110. virtual bool sendData(uint8_t * Data, int DataSize);
  111. #endif
  112. virtual bool reconnect(void);
  113. virtual bool isNetworkLink(void)
  114. {
  115. return true;
  116. }
  117. };
  118. #endif