Hi Chris,
I do not see any issues with your code. It seems to create the payload you are expecting.
The rosstalk.sendAsBytes will parse each ascii-encoded byte into its binary equivalent and send that byte array. So your code would send the binary byte array:
[0x12, 0x00, 0x1f, 0x00, 0x00, 0x08, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x01]
Is it possible the packet sender is sending the bytes as ascii instead of binary? I would be curious to see how the two messages compare when captured in Wireshark.
Please let me know if you have any questions.
------------------------------
Dave Sampson
Ross Video
------------------------------
Original Message:
Sent: 10-19-2021 09:39
From: chris kean
Subject: TCP Control of Utah Scientific Router
I am working on a grid to control a Utah UDS100 frame with SC40E control system.
I am missing something and hope someone can fill in the gap. I can control the router with a packet sender and the control system responds and makes the route.
Command sent with Packet Sender- 12 00 1f 00 00 08 00 10 00 0e 00 00 00 01
RCP4 take: ip = 0xc0a80115, src = 16, dst = 14, levels = 0x00000001 node 0UTAH router take: input 16, output 14, levels 0x00000001
But sending the same command with rosstalk.sendAsBytes results in an error on the control system.
RCP4 take: ip = 0xc0a80115, src = 16, dst = 14, levels = 0x00000001 node 0UTAH router take: input 16, output 14, levels 0x00000001newSockSrv.c 849: ERROR reading I/O stream 3 0 0
Here is what I have so far-
function decimalToHex(d, padding) { var hex = Number(d).toString(16); padding = typeof (padding) === "undefined" || padding === null ? padding = 2 : padding; while (hex.length < padding) { hex = "0" + hex; } return hex;}function callback(success, sentData, resultString, exception){ ogscript.debug("success: " + success); ogscript.debug("sentData: " + sentData); ogscript.debug("resultString: " + resultString); ogscript.debug("exception: " + exception);}//Set Src and Dstvar src= 16;var dst = 14;var chksum = src+dst+1;//Convert to Hexvar hexsum = decimalToHex (chksum); var hexSrc = decimalToHex (src); var hexDst = decimalToHex (dst); //Set Payload Datavar dataone = '12 00 ' +hexsum +' 00 00 08';var datatwo = ' 00 ' +hexSrc +' 00 ' +hexDst +' 00 00 00 01';var payload = '12 00 ' +hexsum +' 00 00 08' +' 00 ' +hexSrc +' 00 ' +hexDst +' 00 00 00 01';//ogscript.debug (dataone +' ' +datatwo);ogscript.debug('Payload- ' +payload);ogscript.debug ('Source = ' +src +' Hex- ' +hexSrc +' Destination = ' +dst +' Hex- ' +hexDst +' Checksum= ' +chksum +' HexSum- ' +hexsum);//Send message to Routerrosstalk.sendAsBytes('10.175.5.230', 5001, payload, callback);
-Chris
------------------------------
chris kean
Community Focus
------------------------------