Home AMX User Forum NetLinx Studio
Options

Sending a string and getting an odd result

Hi all,
I am sending a Hex string to a Projector from raw Hex characters and have to calculate the Checksum. While I have no problem with the checksum calculation, when I send it to the projector it is being changed to 0W.

for example:

SEND_STRING dvPj, "$00,$85,$00,$D0,$01,$01,$00,$57" //Status request
Checksum = 157, use lower of 57
What I see being sent is: Line 2 (07:55:44):: String To [5002:1:1]-[#0#133#0#208#1#1#0W]
Which the projector sees as an incorrect string, and sends no feedback.
Can anyone tell me why the final checksum is being changed to 0W? And what can I do to make it stay the actual character I need?

I appreciate any feedback!

Frustratedly yours,
Tim.

Comments

  • Options
    GregGGregG Posts: 251
    Netlinx debug output tries to change all hex data into ascii printable characters if possible. $00 is not printable (like all the preceeding hex numbers) so it gets printed as the decimal number equivalent #0. But $57 in the ascii table lines up with the letter 'W' - so that gets printed into the debug output instead. ( ** So debug is showing that you sent what you wanted to send, the problem must be something else)

    Personally, I use debugging send_string 0 functions that I created for this, so I can get a more readable format in the telnet session.
    /////////////////////////////////////////////////////////////
    // Char[1000] PrintHex(Char cString[])
    //	Takes an incoming ASCii string up to MAX_PRINTHEX_INPUT chars
    // and outputs a hex byte representation of that string.
    // eg- cCmd = {$23,$5A,$FF} would print as:
    // "23:5A:FF"
    /////////////////////////////////////////////////////////////
    Define_Function Char[MAX_PRINTHEX_OUTPUT] PrintHex(Char cString[])
    {
    Stack_Var Char cOutput[MAX_PRINTHEX_OUTPUT]
    Stack_Var Char cTempStr[MAX_PRINTHEX_INPUT];
    Stack_Var Char cTmp
    
    	If (Length_String(cString) AND (Length_String(cString) <= MAX_PRINTHEX_INPUT))
    	{
    		cTempStr = cString;
    		cOutput = '"';
    		While(Length_String(cTempStr))
    		{
    			cTmp = Get_Buffer_Char(cTempStr)
    
    			cOutput = "cOutput,RIGHT_STRING("'0',ItoHex(cTmp)",2)";
    
    			If(Length_String(cTempStr)) cOutput = "cOutput,':'";
    		}
    		cOutput = "cOutput,'"'"
    	}
    	Else If(Length_String(cString))
    	{
    		_debug(__LINE__,DEBUG_NOTICE,"'PrintHex incoming string length: ',Itoa(Length_String(cString)),' exceeds maximum default, increase your constant size or break up your calls.'")
    	}
    	Return cOutput;
    }
    
    DEFINE_EVENT
    
    Button_Event[dvTP,1]
    {
            Push:
            {
                    Send_String dvProj,"$00,$85,$00,$D0,$01,$01,$00,$57"
                    Send_String 0,"'Sent to dvProj: ', PrintHex("$00,$85,$00,$D0,$01,$01,$00,$57")"
            }
    }
    
  • Options
    DHawthorneDHawthorne Posts: 4,584
    W is $57 (in ASCII). Make sure you are converting it properly before sending, I have to assume you are building that string with the checksum before sending it, and that is where it's going wrong. It's getting converted *again* somewhere along the line and getting sent out ASCII instead of hex. If I had to guess, I'd say you were using ITOHEX in building the final string. Don't, just tag it on like "<rest of string>, <checksum>". You don't have to convert anything for the actual command string.
  • Options
    tbelltbell Posts: 10
    Thanks

    Thanks Guys!
    From the sound of it, I was over reacting to what I was "Seeing" in the send string in the output bar.
    I did send the string using the way you suggested Send_String dvPJ, "string,chksum" and it works for every other command that I have (inputs, power, etc.)
    Thanks for the clarification, and the cool trick!
Sign In or Register to comment.