/********************************************************************* * * JLINKMEM_Process * * Function description * This function should be called more or less regularily to allow * memory reads while the application progam is running. * The more often it is called, the higher the transfer speed. */ void JLINKMEM_Process(void) { if (OS_IsRunning()) { /* No communication until the embOS starts */ if (!_IsInited) { _Init(); _IsInited = 1; } if (HOST_CON) { /* Do nothing until the host connects to us */ // // Handle Timeout timer // if (_TxTimeoutTimer != 0) { _TxTimeoutTimer--; if (_TxTimeoutTimer == 0) { _TxTimeout = 1; } } if (_TxTimeout) { HOST_CON = 0; _TxTimeout = 0; _TxIsPending = 0; _DropTxData(); RX_CNT = 0; /* Drop all bytes form receiving buffer. */ } else { _Receive(); _Send(); } } } }
/********************************************************************* * * _Client */ static void _Client(void * p) { long TCPSockID; struct sockaddr_in ServerAddr; int ConnectStatus; int r; // // Wait until link is up and network interface is configured. // while (IP_IFaceIsReady() == 0) { OS_Delay(50); } while(1) { TCPSockID = socket(AF_INET, SOCK_STREAM, 0); // Open socket if (TCPSockID == 0) { // Error, Could not get socket while (1) { BSP_ToggleLED(0); OS_Delay(20); } } else { // // Connect to server // BSP_SetLED(0); ServerAddr.sin_family = AF_INET; ServerAddr.sin_port = htons(SERVER_PORT); ServerAddr.sin_addr.s_addr = htonl(SERVER_IP_ADDR); ConnectStatus = connect(TCPSockID, (struct sockaddr *)&ServerAddr, sizeof(struct sockaddr_in)); if (ConnectStatus != SOCKET_ERROR) { while(1) { if (DIRECTION & 1) { r = _Receive(TCPSockID); if (r == -1) { break; } _Statistics.RxCnt++; } if (DIRECTION & 2) { r = _Send(TCPSockID); if (r == -1) { break; } _Statistics.TxCnt++; } OS_Delay(50); } } } _Statistics.ErrCnt++; closesocket(TCPSockID); OS_Delay(1000); } }
receive_return_type OSC_Base::Receive(const char *buffer, size_t len, OSC_Base *origin) { return _Receive(buffer, len, origin); }