Hi, UDP socket stream now works on a real ctrlx core. You have to use the address 0.0.0.0 for binding the socket. (NBS.UDP_Peer) The application sends a packet to the android mobile app (SensorDroid) and then receives continuously sensor data from the mobile (via WLAN). It seems that a sample rate of 100 Hz (10 ms) is possible. The PLC app puts the orientation angle on the datalayer as an example. (Project file attached, remove the txt ending) fbSocket(xEnable := TRUE, itfIPAddress := sLocalIP, uiPort := 53122);
IF xSend THEN
fbSend(xExecute := xSend,
itfPeer := fbSocket.itfPeer,
itfIPAddress := GVL.sIpAddr,
uiPort := 53121,
udiSize := SIZEOF(sSendMsg),
pData := ADR(sSendMsg));
xSend := FALSE;
END_IF
fbReceive(xEnable := (fbSocket.itfPeer <> NBS.CAA.gc_hINVALID),
xReady => xReceived,
itfPeer := fbSocket.itfPeer,
udiSize := 512,
pData := ADR(sRcvMsg));
IF xReceived THEN
IL_StrSplit(ADR(sRcvMsg),'$40',0,TRUE,ADR(sData),SIZEOF(sData));
IL_StrSplit(sData[2],'$24',0,TRUE,ADR(sElements),SIZEOF(sElements));
iTimeDiff := ULINT_TO_UINT(iTimestamp_act - iTimestamp_old);
iTimestamp_old := iTimestamp_act;
iTimestamp_act := STRING_TO_ULINT(sElements[1]^);
IL_StrSplit(sData[5],'$24',0,TRUE,ADR(sElements),SIZEOF(sElements));
rOrientation[0] := STRING_TO_REAL(sElements[1]^);
rOrientation[1] := STRING_TO_REAL(sElements[2]^);
rOrientation[2] := STRING_TO_REAL(sElements[3]^);
END_IF
... View more