Home AMX User Forum NetLinx Studio

Having problem to find a solution.

I have a file that has some data.
Like:
0000:f0
0001:02
0002:14
0003:00
0004:00
0005:01
0006:01
0007:36
0008:00
0009:80
000a:1c
000b:00
000c:00
000d:4e
000e:65
000f:77
0010:20

Now i need to send the data to a serial port.
I only need the last 2 of line 1.
So from line 1 i have F0. but i want it send like a HEX value $F0 to the port.
I need to send every line after the other.
I try a lot to have it work but i dont see it anymore.

I am reading the file, reading line 1 and get the last 2 with right_string(buffer,2)

is there someone that can help me?

Comments

  • I have a file that has some data.
    Like:
    0000:f0
    0001:02
    0002:14
    0003:00
    0004:00
    0005:01
    0006:01
    0007:36
    0008:00
    0009:80
    000a:1c
    000b:00
    000c:00
    000d:4e
    000e:65
    000f:77
    0010:20

    Now i need to send the data to a serial port.
    I only need the last 2 of line 1.
    So from line 1 i have F0. but i want it send like a HEX value $F0 to the port.
    I need to send every line after the other.
    I try a lot to have it work but i dont see it anymore.

    I am reading the file, reading line 1 and get the last 2 with right_string(buffer,2)

    is there someone that can help me?

    I think HEXTOI() will do what you want. If you take the string that you get with your right_string() and do HEXTOI() on that result, you'll get an integer that has the same value as the hex characters. For instance, F0 in ASCII will turn into 240 in an integer variable. Then you can do send_string to send the string to the serial device. Here's the basic code for just that part...
    cTemp = right_string(buffer,2)
    
    nTemp = HEXTOI(cTemp)
    
    send_string dvDevice, "nTemp"
    

    I've tested something similar and it does exactly what you want. Hope that helps.
  • yes

    iT WORKS... Thanks a lot, now i can sleep tonight.
  • iT WORKS... Thanks a lot, now i can sleep tonight.

    Glad I could help.
Sign In or Register to comment.