Sending Hex through serial port

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by alexm, Aug 16, 2005.

  1. alexm

    alexm

    Joined:
    Aug 15, 2005
    Messages:
    27
    Likes Received:
    1
    Location:
    Wellington
    Hi,

    I'm trying to send a hex string out of the colour touch screen through the serial port. I have tried the following string combinations but all have not worked, ( im a trying to talk to a russound amp using the rnet protocol).
    The serial port itself is working as I am revieving comms from the amp.

    Can the colour touch screen send hex values, ie is there a special combination of characters needed?

    String sample:

    F000007F00007005020200007F0000000000017BF7

    0xF00x000x000x7F0x000x000x700x050x020x020x000x000x7F0x000x000x000x000x000x010x7B0xF7

    /xF0/x00/x00/x7F/x00/x00/x70/x05/x02/x02/x00/x00/x7F/x00/x00/x00/x00/x00/x01/x7B/xF7

    aslo have tried the $ sign as well.
    Any ideas?
     
    alexm, Aug 16, 2005
    #1
  2. alexm

    Richo

    Joined:
    Jul 26, 2004
    Messages:
    1,257
    Likes Received:
    0
    Location:
    Adelaide
    Can you post the extact code you are using to send the strings.
     
    Richo, Aug 16, 2005
    #2
  3. alexm

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Yes. What do you mean by "hex values" ?

    For example, the string 'FF' may be considered a hex string, but is just two 'F' characters in a string. If you want to send the numerical equivalent of FF (the number 255), you can use #255 in the string. See the "String Type" topic in the logic help file for more information.

    I would suggest making sure that you can control the device using hyperterminal or some other serial program first. Once you have definitely got the strings working, then start writing logic code.
     
    Darren, Aug 16, 2005
    #3
  4. alexm

    alexm

    Joined:
    Aug 15, 2005
    Messages:
    27
    Likes Received:
    1
    Location:
    Wellington
    Hey,

    Thanks for the help guys, i managed to get it working using an array of hex characters ie


    HEX : array[0..4] of char;

    HEX[0] := #112; // etc

    Then sending each char seperately in a loop.

    Thanks again,

    Alex
     
    alexm, Aug 23, 2005
    #4
  5. alexm

    rhamer

    Joined:
    Aug 3, 2004
    Messages:
    673
    Likes Received:
    3
    Location:
    Melbourne, Australia
    In my experience, devices that have interface ports that they actually want people to be able to use, tend to use what's known as ASCII HEX. The C-Bus PCI for example uses it (at least in the mode that I know about).

    This is what Darren is referring to previously.

    Basically it usually consists of 2 bytes (or characters if you like) that are ASCII printable characters that when read together form a HEX value.

    For example a device might need the following string to make something happen;

    2367a3f4ee (watch the case ee is not the same as EE)

    This is really a series of separate characters that is interpreted by the target device as the HEX values 23 67 a3 f4 ee even though they are just sent as normal ASCII characters.

    To be exact if you send the ASCII character 2 you are actually sending the HEX character 32 or the octal character 062 or the or the decimal character 50 or even the binary character 110010, they are all exactly the same thing just represented differently.

    The reasons for manufacturers choosing this scheme is primarily (in my understanding) ease of interfacing, you can use something as simple as a ASCII dumb terminal to manually type out the commands on a keyboard (hyperterminal is an example of a terminal emulator running on a PC) all the way up through embedded controllers such as a PIC microcontroller to C-BUS PAC type devices to mainframe computers with equal ease (well almost).

    So the short point here is most things can be controlled by just sending a series of simple characters and not have to worry about whether it is hex or whatever, and the way to test it is to fire up hyperterminal and start typing.

    One word of warning though, if you are trying to interface to something that is not generally open for anyone to use, for example you may be trying to control a programmable thermostat that is designed only to mate with the manufactures own controller then all bets are off. In that case it probably could still be done but the communication would most likely be a more efficient actual HEX based protocol.
     
    rhamer, Aug 23, 2005
    #5
  6. alexm

    Lance_M

    Joined:
    Aug 6, 2004
    Messages:
    4
    Likes Received:
    0
    Location:
    Southampton
    Hi,
    I've got my hex strings to work fine out of the serial port by listing them in the constants section and calling the sting e.g.

    s = #13#01 etc etc...

    but I'm trying to send a 00h out of the serial port using. I've tried #00 but get nothing actually sent by the port.
    Can anyone help?
    Cheers

    Lance
     
    Lance_M, Oct 9, 2005
    #6
  7. alexm

    Phil.H

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

    Lance I think Darren is on leave this week. I have been doing some work on serial so I may be able to help. Try the following code in a module:

    once {some sort of control like a group address on} then
    begin
    WriteSerial (1, '00h'#13);
    end;

    {The code above will send the ASCII characters "00h" followed by the ASCII control for Carriage Return. Assumption made that you are using serial port #1. You also need to be aware of serial cable pinouts (crossover pins 2 & 3 or straight) also the need to power the serial circuits on the PAC via the 24v AC terminals.

    Let us know how you get on.
     
    Phil.H, Oct 11, 2005
    #7
  8. alexm

    Lance_M

    Joined:
    Aug 6, 2004
    Messages:
    4
    Likes Received:
    0
    Location:
    Southampton
    Hi Phil,

    Thanks for the quick post, what I should have said is I'm trying to get the ascii code 00 (the null character according to the ascii tables) to come out of the port.
    The device I'm trying to control needs to see the command string

    02 00 00 00 00 02 in hex format so the string I need to send is

    02#???

    Cheers
     
    Lance_M, Oct 12, 2005
    #8
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.