TCP communication with XDK
응답
16. 10. 12 오후 4:43

Hi Bosch tech support team,

I want to communicate with XDK through TCP apart from XDK sensor monitor. could you guide me to communicate with XDK in TCP communication

 

Thank you.

0 (0 투표)
RE: TCP communication with XDK
응답
16. 10. 13 오전 9:26 as a reply to Thangarasu Ponnuchamy.

Hello Thangarasu,

the XDK library socket.h and the SendDataOverUdp example provide all you need to establish a connection to the XDK via TCP.  It also contains explanations about how to send or receive data.

Please take a look at the following two examples about how to send and receive data from a TCP socket.

 

// Receiving data from a TCP socket

SlSockAddrIn_t  Addr;
SlSockAddrIn_t  LocalAddr;
_i16 AddrSize = sizeof(SlSockAddrIn_t);
_i16 SockID, newSockID;
_i16 Status;
_i8 Buf[RECV_BUF_LEN];

LocalAddr.sin_family = SL_AF_INET;
LocalAddr.sin_port = sl_Htons(5001);
LocalAddr.sin_addr.s_addr = 0;

Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons(5001);
Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));

SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
Status = sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
Status = sl_Listen(SockID, 0);
newSockID = sl_Accept(SockID, (SlSockAddr_t*)&Addr, (SlSocklen_t*) &AddrSize);
Status = sl_Recv(newSockID, Buf, 1460, 0);

// Sending data to a TCP socket

SlSockAddrIn_t  Addr;
_i16 AddrSize = sizeof(SlSockAddrIn_t);
_i16 SockID;
_i16 Status;
_i8 Buf[SEND_BUF_LEN];

Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons(5001);
Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));

SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
Status = sl_Connect(SockID, (SlSockAddr_t *)&Addr, AddrSize);
Status = sl_Send(SockID, Buf, 1460, 0 );

 

Please don't hesitate to ask, if you have further questions.

Kind regards,
Franjo

0 (0 투표)
RE: TCP communication with XDK
응답
16. 10. 13 오전 11:16 as a reply to Franjo Stjepandic.

Hello Franjo

Thank you for your support, actually i am able to communicate with XDK using DSM_demoSensorMonitor application(for result please reff image). Now I want to implement the own application(Java) to send and receive the sensor information using TCP. Please provide the suggestions.

Kind Regards

Thangarasu

0 (0 투표)
RE: TCP communication with XDK
응답
16. 10. 13 오후 1:46 as a reply to Thangarasu Ponnuchamy.

Hello Thangarasu,

unfortunately we can provide support for the XDK implementation only.
To send data with the XDK you need to implement an application with the XDK Workbench in C according to the example code I posted in the previous post. To get a deeper understanding of the communication I would recommend to take a look at the SendDataOverUDP example in the XDK workbench because it has a similar program structure.

For receiving data with and Java application on your computer I recommend stackoverflow (stackoverflow.com) that provides several GUI client examples in java.

Kind regards,
Franjo

0 (0 투표)
RE: TCP communication with XDK
응답
16. 10. 14 오후 3:49 as a reply to Franjo Stjepandic.

Hi Franjo,

Thanks for your support.

0 (0 투표)
RE: TCP communication with XDK
응답
16. 10. 17 오전 9:13 as a reply to Thangarasu Ponnuchamy.

Hello Thangarasu,

I am glad to help.

Please don't hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 투표)