We are trying to connect to one of our hardware units with a tablet or phone. We have been doing it with WinDev for years via a computer. It has worked fine over the years. Using the same method with WinDev Mobile 23 seems to have a small bug. In the emulator it works. When loaded on a phone or tablet extra bytes show up or even an extra byte overwrites some of the data we are trying to retrieve.
We send and receive all data in 60 byte chunks.
When the data is retrieved by a phone or tablet, there is usually 62 bytes. Expected, AA BB CC 02 2A 2A 2A 2A 50 72 6F 76 69 64 65 6E.....20
Actual, FD FF BB CC 02 2A 2A 2A 2A 50 72 6F 76 69 64 65 6E....20 FF (FF tacked onto the end)
Test Code below.
bufUserPage2 is Buffer on 60 = [0xaa,0xbb,0xcc,0x02] //unit name, F or C, IP address bufTest is Buffer on 60 = [0x2a,0xcd,0xdc,0xba] //Model number, Family, Revision etc.
j is int rslt is boolean ReadError is string IP is string ReturnBuffer is Buffer
STC_size = Length(bufUserPage2) ListAdd(LIST_One,"size of buffer " + Length(bufUserPage2) + CR) IP = EDT_IP_Address
FOR j = 5 TO 60 bufUserPage2[[j]] = 0x00 //Padding the buffer to 60 for phones and tablets END
ListAdd(LIST_One,"size of buffer " + Length(bufUserPage2) + CR)
Socket.Option = SocketNagleOff rslt = SocketConnect("sc",10001, IP,5000) IF rslt = False THEN EDT_Buffer = "Failed to connect" ReadError = "Failed to connect with " + IP Info(ReadError) ListAdd(LIST_One,"failed to connect" + CR) //for troubleshooting ErrorInfo(errFullDetails) ELSE ListAdd(LIST_One,"connected" + CR) //for troubleshooting rslt = SocketChangeTransmissionMode("sc",SocketNoEndTag,"THE-END") IF rslt = False THEN SocketClose("sc") ReadError = "Unable to change Transmission Mode to 'socketnoendtag'" Info(ReadError) ListAdd(LIST_One,"transmission mode failed" + CR) //for troubleshooting ELSE EDT_Buffer = "Changed trans" ListAdd(LIST_One,"transmission mode OK" + CR) END ListAdd(LIST_One,Length(ReturnBuffer) + CR) //for troubleshooting SocketWrite("sc",bufUserPage2) cntr is int = 0 LOOP ReturnBuffer = ReturnBuffer + SocketRead("sc", False, 5000) // 3 second timeout cntr += 1 STC_size = "wait" DO WHILE Length(ReturnBuffer) < 60 AND cntr < 9 // 4/12/17 was cntr < 7 // junk is buffer = SocketRead("sc", False, 5000) // ListAdd(LIST_One,"junk is " + junk + CR) //for troubleshooting SocketClose("sc") EDT_Buffer = BufferToHexa(ReturnBuffer) STC_size = Length(ReturnBuffer) END |