Hex as a control string

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by richy, Jan 25, 2006.

  1. richy

    richy

    Joined:
    Aug 8, 2004
    Messages:
    88
    Likes Received:
    0
    Location:
    VIC
    Hi guys,

    This may sound lame, But i'm tired, I've looked at code all day, the answer is probably in front of me.

    My projector accepts Hex control strings via rs232. Using a third party device I can send the command without a problem. Works every time.

    But I cant seem to send the same command via a HomeGate or PAC com port.
    All my other devices take ASCII, except this dam projector, and I have been senidng commands from HomeGate and PAC to my other devices without a drama.

    The Hex command is :-
    BE EF 03 06 00 BA D2 01 00 00 60 01 00

    how do I write this via a serial com port.
    I cant seem to make it work. I've tried # symbol before each byte. But get compile errors.

    I'm pulling my hair out.

    anyone got any suggestions.
     
    richy, Jan 25, 2006
    #1
  2. richy

    rhamer

    Joined:
    Aug 3, 2004
    Messages:
    673
    Likes Received:
    3
    Location:
    Melbourne, Australia
    rhamer, Jan 25, 2006
    #2
  3. richy

    mikegriff

    Joined:
    Aug 3, 2004
    Messages:
    158
    Likes Received:
    3
    Location:
    Wales
    Let us know how you get on because I will need to send
    AA,55,03,01,01
    in Hex
    thanks
    Mike
     
    mikegriff, Jan 25, 2006
    #3
  4. richy

    Phil.H

    Joined:
    Jul 29, 2004
    Messages:
    466
    Likes Received:
    0
    Location:
    Sydney
    Hex messages

    richy

    Have not had the need to communicate with devices using straight hex so this is a stab in the dark.

    Try either quoting using the $ eg '$03' or declaring string constants using the $ also.

    The other option is to use the "serial in test" program in the link below to see exactly what messages are floating around on the serial comms cct. This will require the unit you are trying to work with, sending out serial comms when it is operated manually.
    http://www.cbusforums.com/forums/showthread.php?t=1951

    Let us know how you get on.
     
    Phil.H, Jan 26, 2006
    #4
  5. richy

    alexm

    Joined:
    Aug 15, 2005
    Messages:
    27
    Likes Received:
    1
    Location:
    Wellington
    To send a hex string first create a string variable to hold the string say:

    HEX_STRING : string; // do this in Global Variables

    Now you need to convert each hex byte into a decimal number, the hex string FF, 05, 06, F7 would then become 255, 05, 06, 247. You then assign the decimal numbers to the string variable created as below:

    HEX_STRING := #255#05#06#247; // do this in Initialisation

    you can then send the string down the serial port with the write serial function as below:

    WriteSerial(1, HEX_STRING); // to send the string down serial port 1
     
    alexm, Jan 26, 2006
    #5
    jasonwall likes this.
  6. richy

    Phil.H

    Joined:
    Jul 29, 2004
    Messages:
    466
    Likes Received:
    0
    Location:
    Sydney
    From the PICED Logic Help File

    This may help...

    Hexadecimal Constants

    Hexadecimal numbers can be represented by placing a dollar ($) sign in front of a number. For example :

    Hexadecimal Constant Value
    $00 0
    $FF 255
    $0B00 2816
    $FFFFFF 16777215
    The range is from $0 to $FFFFFF.

    Let us know...
     
    Phil.H, Jan 27, 2006
    #6
  7. richy

    richy

    Joined:
    Aug 8, 2004
    Messages:
    88
    Likes Received:
    0
    Location:
    VIC
    Ok, before I rip this F@#$@#$! projector of the F!@$#% Ceiling.

    what I have tried.

    double checked the Rs232 conenctions, pin configutrations are correct.
    Sent a command from a third party device, just to check I'm not going insane. that works too.

    But sending a HEX string from HomeGate, I just cant get it to work. Methods I have tried are as follows.

    the string is : BE EF 03 06 00 BA D2 01 00 00 60 01 00
    no carriage return or line feed needed.
    which translates to : #190#239#03#06#00#186#210#01#00#00#96#01#00
    in decimal ...

    ***************************************************

    1.
    As alexm has suggested. the code was as follows.
    {Global variables section}
    HEX_STRING : string;

    {initialisation section}
    HEX_STRING := #190#239#03#06#00#186#210#01#00#00#96#01#00;

    {Write Serial Module}
    once GetEnableState("HitPJTXOnOff")= ON then
    begin
    WriteSerial (4, HEX_STRING);
    end;

    This method does not work

    ***************************************************

    2.
    This was also a suggestion from alexm
    {Global variables section}
    HEX : array[0..12] of string;

    {initialisation section}
    HEX[0] := #190;
    HEX[1] := #239;
    HEX[2] := #03;
    HEX[3] := #06;
    HEX[4] := #00;
    HEX[5] := #186;
    HEX[6] := #210;
    HEX[7] := #01;
    HEX[8] := #00;
    HEX[9] := #00;
    HEX[10] := #96;
    HEX[11] := #01;
    HEX[12] := #00;

    {Write Serial Module}
    once GetEnableState("HitPJTXOnOff")= ON then
    begin
    {for x := 0 to 12 do}
    WriteSerial (4, HEX[x]);
    {x := x +1;}
    end;

    This dont work.

    ***************************************************

    3.
    more of the same re-worked.

    {Write Serial Module}
    once GetEnableState("HitPJTXOnOff")= ON then
    begin
    WriteSerial (4, #190#239#03#06#00#186#210#01#00#00#96#01#00);
    end;

    dont work.

    ***************************************************

    4.

    {Write Serial Module}
    once GetEnableState("HitPJTXOnOff")= ON then
    begin
    WriteSerial (4, #190);
    WriteSerial (4, #239);
    WriteSerial (4, #03);
    WriteSerial (4, #06);
    WriteSerial (4, #00);
    WriteSerial (4, #186);
    WriteSerial (4, #210);
    WriteSerial (4, #01);
    WriteSerial (4, #00);
    WriteSerial (4, #00);
    WriteSerial (4, #96);
    WriteSerial (4, #01);
    WriteSerial (4, #00);
    end;

    dont work

    ***************************************************
    5.
    {Write Serial Module}
    once GetEnableState("HitPJTXOnOff")= ON then
    begin
    WriteSerial (4, '$BE$EF$03$06$00$BA$D2$01$00$00$60$01$00');
    end;

    dont work.

    ***************************************************
    first of all thanks for everyones input, its been great ...

    I dont know what else to do ....
    help me please ...:confused:

    cheers
     
    Last edited by a moderator: Jan 29, 2006
    richy, Jan 29, 2006
    #7
  8. richy

    rhamer

    Joined:
    Aug 3, 2004
    Messages:
    673
    Likes Received:
    3
    Location:
    Melbourne, Australia
    Are you absolutely sure it's hex you need and not ASCII hex?

    What is the third party program you are using to talk to it?
     
    rhamer, Jan 29, 2006
    #8
  9. richy

    richy

    Joined:
    Aug 8, 2004
    Messages:
    88
    Likes Received:
    0
    Location:
    VIC
    Hi thanks for the prompt reply.

    Yep 100% its HEX.

    I have sent ASCII code to other devices, e.g. Denon AMP, Axium Multizone controller etc...
    They work, when sent ASCII every time.

    The ASCII equivilant of the HEX string I am trying to send, does not make sense.
    I have tried sending this, but that did not work either.

    But I am about to give that method another go ...

    The thirdparty program I am using, well actually a device. RTI T3 Remote control system.

    It has the ability to configure its output ports to send RS232. In the config window you can enter the Port settings, and the String you wish to send.
    This has a toggle button between HEX/ASCII.

    When I enter the HEX string into the properties window, with HEX selected. Download the program, and press the key associated with this string, it fires the projector on or off, every time.
     
    richy, Jan 29, 2006
    #9
  10. richy

    richy

    Joined:
    Aug 8, 2004
    Messages:
    88
    Likes Received:
    0
    Location:
    VIC
    Can anyone convert this Hex to ASCII

    HEX : BE EF 03 06 00 BA D2 01 00 00 60 01 00

    ASCII =
     
    richy, Jan 29, 2006
    #10
  11. richy

    rhamer

    Joined:
    Aug 3, 2004
    Messages:
    673
    Likes Received:
    3
    Location:
    Melbourne, Australia
    Ok, as I have said before, I'm no PAC programmer.

    BTW some people are telling you to prefix the commands with # to indicate they are hex values, but you are then sending them as decimal eg #190 instead of #BE.

    Others are telling you to prefix them with $.

    Only one of them can be right, is there nothing in the PAC manual?
     
    rhamer, Jan 29, 2006
    #11
  12. richy

    richy

    Joined:
    Aug 8, 2004
    Messages:
    88
    Likes Received:
    0
    Location:
    VIC
    Yeah, I have tried the # prefix, it compiles when I use the decimal value.

    but when trying to use the Hex value after the prefix it does not compile at all.
    the error is:
    "Error C006 : Illegal symbol"
    Yet the Logic.PDF manual actually states.
    "A control string is a sequence of one or more control characters, each of which consists of the # symbol followed by an unsigned integer constant from 0 to 255 (decimal or hexadecimal) and denotes the corresponding ASCII character."
    So the manual has got me stuffed.

    The actual HEX value converted to a string = "?? ?? ` " that's without the quotes. Wow, never seen a string like that before.

    In decimal ASCII it converts to =
    "190, 239, 3, 6, 0, 186, 210, 1, 0, 0, 96, 1, 0"
    which is what I calculated before.
     
    richy, Jan 29, 2006
    #12
  13. richy

    alexm

    Joined:
    Aug 15, 2005
    Messages:
    27
    Likes Received:
    1
    Location:
    Wellington
    Hex comm tool

    I suggest that you connect to the projector you are trying to control and actually watch the hex strings spitting out of the unit.
    You can do this with a program called "RS232 Hex Comms Tool" (search for it at download.com). This tool allows you to connect via a serial port and display any strings that come through, the strings can also be displayed as HEX numbers or there ASCII counter parts.

    Another note: do you have to send a checksum with the command string?, because if you do the unit could be ignoring your sent strings with no checksum attached.

    You cant convert these strings to ASCII equivelant as the bytes under HEX 20 are non-printable characters (you cant type these with your keyboard)
     
    Last edited by a moderator: Jan 29, 2006
    alexm, Jan 29, 2006
    #13
  14. richy

    richy

    Joined:
    Aug 8, 2004
    Messages:
    88
    Likes Received:
    0
    Location:
    VIC
    Thanks,

    I'll do "RS232 Hex Comms Tool" and let you know ...

    As far as a checksum, nothing is needed. I'm placing exactly the same HEX code into the RTI programming software, and it works ok.

    This has turned out to be more of a challange than I expected...
     
    richy, Jan 29, 2006
    #14
  15. richy

    alexm

    Joined:
    Aug 15, 2005
    Messages:
    27
    Likes Received:
    1
    Location:
    Wellington
    Welcome to the World of RS232 :D
     
    alexm, Jan 29, 2006
    #15
  16. richy

    rhamer

    Joined:
    Aug 3, 2004
    Messages:
    673
    Likes Received:
    3
    Location:
    Melbourne, Australia
    Another thing to consider is the state of the control lines.

    You might find that the device will ignore any commands unless one or more of the control lines are set correctly.

    Your third party tool may be setting them implicitly.

    A cheap break out box will show you what's going on.
     
    rhamer, Jan 29, 2006
    #16
  17. richy

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Sorry about that. The manual is wrong and will be fixed. You can only have a decimal value in a character constant.
     
    Darren, Jan 29, 2006
    #17
  18. richy

    richy

    Joined:
    Aug 8, 2004
    Messages:
    88
    Likes Received:
    0
    Location:
    VIC
    Just a thought, I think you refering to the other pins, i.e. RTS, CTS, and DTS.

    Is this what you are refering to ??

    If so, I'm afraid it may be a dead end. The reason I say this:- The RTI RS232 pin out only requires TD, RD and GND, and I have already established that the projector works when I send the HEX via the RTI.
     
    Last edited by a moderator: Feb 1, 2006
    richy, Feb 1, 2006
    #18
  19. richy

    richy

    Joined:
    Aug 8, 2004
    Messages:
    88
    Likes Received:
    0
    Location:
    VIC
    Alex,
    I'm interested in this tool, I have not downloaded it yet, but I will. However, what is interesting to me is. Can I utilze the tool to see what is coming out of the RTI with respect to what is coming out of the HomeGate serial port.

    If so, this TOOL is GOLD !!!, and I cant wait to donload it..

    Cheers mate.

    Everyone has been so helpful, once again thanks to everyone, for the feedback.
     
    richy, Feb 1, 2006
    #19
  20. richy

    rhamer

    Joined:
    Aug 3, 2004
    Messages:
    673
    Likes Received:
    3
    Location:
    Melbourne, Australia
    If your asking if this can get in the middle of a connection between 2 devices, then the answer is no, not easily.

    What you are looking for in that case is a protocol analyser.

    You could also try a piece of software called "HDD Serial Monitor" that will perform a bit of trickery to do a simmilar thing. You can download a trial version from http://www.hhdsoftware.com/sermon.html

    How it works is it creates a virtual com port (unknown to your software) that the application software (like homegate/c-gate) then connects to. The serial monitor software then connects to the real port and marshalls traffic through it.

    So it can display in real time the traffic moving in both directions.

    I still prefer a real instrument, because I can use it between any devices (like your PAC & projector), not just a PC and a device, but in the absence of one of those, give HDD Serial Monitor a go
     
    Last edited by a moderator: Feb 1, 2006
    rhamer, Feb 1, 2006
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.