RTCS_selectall and RTCS_selectset

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

RTCS_selectall and RTCS_selectset

2,177件の閲覧回数
gionny
Contributor II

Hi all,

 

I'm using K60 (tower board) and MQX 3.7

 

I'd like to use socket to receive UDP packets (800bytes every 32ms) in 2 different ports.

 

I have tried to use RTCS_selectall but I lose some packets.

So I'have tried this simple code:

 

....

_int_install_unexpected_isr();

 

// Inizialize networking

initialize_networking();

 

// local address initialization
laddr.sin_family = AF_INET;
laddr.sin_port = 2500;
laddr.sin_addr.s_addr = INADDR_ANY;

 

// Create a datagram socket:
socklist[ID_SOCKET_SDO] = socket(PF_INET, SOCK_DGRAM, 0);
if (socklist[ID_SOCKET_SDO] == RTCS_SOCKET_ERROR) {
printf("\nFailed to create datagram socket.");
_task_block();
}

 

// Bind the datagram socket to the UDP port:
error = bind(socklist[ID_SOCKET_SDO], &laddr, sizeof(laddr));
if (error != RTCS_OK) {
printf("\nFailed to bind datagram - 0x%lx.", error);
_task_block();
}

 

laddr.sin_port = 2501;

// Create a datagram socket:
socklist[ID_SOCKET_PROFILO_MOTO] = socket(PF_INET, SOCK_DGRAM, 0);
if (socklist[ID_SOCKET_PROFILO_MOTO] == RTCS_SOCKET_ERROR) {
printf("\nFailed to create datagram socket.");
_task_block();
}

 

// Bind the datagram socket to the UDP port:
error = bind(socklist[ID_SOCKET_PROFILO_MOTO], &laddr, sizeof(laddr));
if (error != RTCS_OK) {
printf("\nFailed to bind datagram - 0x%lx.", error);
_task_block();
}

 

// Echo server

// error = ECHOSRV_init("EchoServer", 17, 1000);
// if (error != RTCS_OK) {
// printf("\nFailed to echo server init - 0x%lx.", error);
// _task_block();
// }

 

while (TRUE) {

// prepare recevive structs
GPIOA_PDOR ^= BIT_29; // green led TOGGLE
sock = RTCS_selectset(socklist, NUM_SOCKET_WAITING, 100);

...

}

 

If I stop the sender device, I suppose I have to see every 100ms my led toggle.

This doesn't happen, the timeout is... random. Sometimes is bigger than a second.

Why?

 

Thank you

G

ラベル(1)
タグ(1)
0 件の賞賛
返信
3 返答(返信)

1,400件の閲覧回数
BryGuyH
Contributor IV

Yes there are flaws in rtcs when it comes to select. You don't happen to be using PPP are you? If you are then timeouts will never work since the ppp driver has infinite loops in it.

1,400件の閲覧回数
ThiagoE
Contributor I

Hi,

 

I am having the same problem in MQX 3.7 and CW MCU v10.1. My code open a UDP socket and when I use RTCS_select or RTCS_selectall with timeout,  the same is random and sometimes never returns until a message in the socket is received.

 

Best Regards

Thiago 

0 件の賞賛
返信

1,400件の閲覧回数
ggary
Contributor I

If there a bug here?  I'm having the same problem with MQX 3.7. 

 

 

0 件の賞賛
返信