Home AMX User Forum NetLinx Studio
Options

serial protocol problems - help needed

Hi all

I am working with ARCAM tuner with rs232 protocol.

I am trying to send this command:

Quote from the protocol:

Select a preset radio station.
Example
Command/response sequence to select preset 12:
COMMAND: 0x21 0x13 0x01 0x0C 0x0D
RESPONSE: 0x21 0x13 0x01 0x01 0x0C 0x0D

When I am sending this command from the telnet for preset 2 like this:

send_string 5001:4:1,$21$13$01$02$0D

its working.
from my program - nothing...I can see the netlinx port number 4 tx led is working but the tuner is not responding.

looking at the notification windows shows the same command - (from some reason it shows the $21 character '!' instead of value)

Same happen to me in other devices too of Kramer. there must be something I am doing wrong here....

I tried everything I know, several string formats, I even made a button event to set the baud rate just to make sure its set.

BTW this device is not sending ONLINE event when its starts, only string event.

Attached are my program and notification window capture.


Thanks for any help

Ady

Comments

  • Options
    adysadys Posts: 395
    Main program

    here is the main program


    PROGRAM_NAME='STUDYROOM'
    (***********************************************************)
    (***********************************************************)
    (* FILE_LAST_MODIFIED_ON: 04/05/2006 AT: 09:00:25 *)
    (***********************************************************)
    (* System Type : NetLinx *)
    (***********************************************************)
    (* REV HISTORY: *)
    (***********************************************************)
    (*
    $History: $
    *)
    (***********************************************************)
    (* DEVICE NUMBER DEFINITIONS GO BELOW *)
    (***********************************************************)
    DEFINE_DEVICE

    // Study room system - > system 1

    // my touch panel devices
    dvTPStudyRoom = 10001:1:1

    // (controller:device:system)

    // Serial devices
    dvSONYFDW32 = 5001:1:1 // LCD TV PRO serial


    dvDENON780 = 5001:2:1 // TAPE DECK
    dvDENON3910 = 5001:3:1 // DVD
    dvARCAM = 5001:4:1 // TUNER
    dvVS1616A = 5001:5:1 // audio matrix
    dvVP84ETh = 5001:6:1 // video matrix


    dvYES1 = 5001:9:1 // YES SET TOP BOX
    dvYES2 = 5001:10:1
    dvYES3 = 5001:11:1

    dvSONYKDL52 = 5001:12:1 // LCD TV BIG IR
    dvSONY640 = 5001:13:1 // VCR IR

    dvGEFENHDMIMatrix = 5001:14:1 // HD matrix

    vdvDenon3910 = 41001:1:1

    dvDebug = 0:0:0


    //send_string 5001:4:0,$21$13$01$02$0D

    (***********************************************************)
    (* CONSTANT DEFINITIONS GO BELOW *)
    (***********************************************************)
    DEFINE_CONSTANT


    (***********************************************************)
    (* DATA TYPE DEFINITIONS GO BELOW *)
    (***********************************************************)
    DEFINE_TYPE

    (***********************************************************)
    (* VARIABLE DEFINITIONS GO BELOW *)
    (***********************************************************)
    DEFINE_VARIABLE

    include 'tunerarcam.axi'
    include 'dvddenon.axi'
    include 'kramer_vs1616'
    include 'kramer_vp84'

    (***********************************************************)
    (* LATCHING DEFINITIONS GO BELOW *)
    (***********************************************************)
    DEFINE_LATCHING

    (***********************************************************)
    (* MUTUALLY EXCLUSIVE DEFINITIONS GO BELOW *)
    (***********************************************************)
    DEFINE_MUTUALLY_EXCLUSIVE


    DEFINE_START

    (* Initialize Devices *)

    SEND_COMMAND dvVS1616A, 'SET BAUD 9600,N,8,1'
    SEND_COMMAND dvVP84ETh, 'SET BAUD 9600,N,8,1'
    SEND_COMMAND dvARCAM, 'SET BAUD 19200,N,8,1'


    (***********************************************************)
    (* THE EVENTS GO BELOW *)
    (***********************************************************)
    DEFINE_MODULE 'Denon_DVD3910_Comm_dr1_0_0' COMM1(vdvDenon3910, dvDENON3910)
    DEFINE_MODULE 'Denon_DVD3910_UI' TP1(vdvDenon3910, dvTPStudyRoom, nTP_BUTTONS, nTXT_BTN)
  • Options
    adysadys Posts: 395
    Arcam module

    The Arcam Module:

    PROGRAM_NAME='ARCAM'


    (*{{PS_SOURCE_INFO(PROGRAM STATS) *)
    (***********************************************************)
    (* FILE CREATED ON: 10/02/2001 AT: 09:51:02 *)
    (***********************************************************)
    (* FILE_LAST_MODIFIED_ON: 10/03/2002 AT: 08:38:12 *)
    (***********************************************************)
    (* ORPHAN_FILE_PLATFORM: 1 *)
    (***********************************************************)
    (*}}PS_SOURCE_INFO *)
    (***********************************************************)
    (* System Type : Netlinx *)
    (***********************************************************)
    (* REV HISTORY: *)
    (***********************************************************)

    //####
    //# File : Rcvr_Tp.axi
    //# Desc : This file handles tuner audio functions for the touch panel.
    //# Notes : None.
    //####

    DEFINE_CONSTANT

    // TUNER TP Button constants
    TUNER_PRESET01 = 1
    TUNER_PRESET02 = 2
    TUNER_PRESET03 = 3
    TUNER_PRESET04 = 4
    TUNER_PRESET05 = 5
    TUNER_PRESET06 = 6
    TUNER_PRESET07 = 7
    TUNER_PRESET08 = 8
    TUNER_PRESET09 = 9
    TUNER_PRESET10 = 10
    TUNER_POWER = 15



    //Tuner commands

    Power_button = '$21$00$01$01$0D'
    Preset01 = '$21$13$01$01$0D'
    Preset02 = '$21$13$01$02$0D'
    Preset03 = '$21$13$01$03$0D'
    Preset04 = '$21$13$01$04$0D'
    Preset05 = '$21$13$01$05$0D'
    Preset06 = '$21$13$01$06$0D'
    Preset07 = '$21$13$01$07$0D'
    Preset08 = '$21$13$01$08$0D'
    Preset09 = '$21$13$01$09$0D'
    Preset10 = '$21$13$01$0A$0D'



    DEFINE_VARIABLE




    VOLATILE INTEGER nTPTunerBtns []=
    {
    TUNER_PRESET01,
    TUNER_PRESET02,
    TUNER_PRESET03,
    TUNER_PRESET04,
    TUNER_PRESET05,
    TUNER_PRESET06,
    TUNER_PRESET07,
    TUNER_PRESET08,
    TUNER_PRESET09,
    TUNER_PRESET10,
    TUNER_POWER
    }




    DEFINE_EVENT

    BUTTON_EVENT[dvTPStudyRoom, nTPTunerBtns]
    {
    PUSH:
    {
    STACK_VAR INTEGER nBtnIndex
    nBtnIndex = GET_LAST(nTPTunerBtns)
    SWITCH(nBtnIndex)
    {
    CASE TUNER_POWER:
    {
    send_string dvARCAM, Power_button
    }
    CASE TUNER_PRESET01:
    {
    send_string dvARCAM, Preset03
    send_string dvDebug, Preset03
    }
    CASE TUNER_PRESET02:
    {
    send_string dvARCAM, Preset02

    }
    CASE TUNER_PRESET03:
    {
    send_string dvARCAM, Preset03
    }
    CASE TUNER_PRESET04:
    {
    send_string dvARCAM, Preset04
    }
    CASE TUNER_PRESET05:
    {
    send_string dvARCAM, Preset05
    }
    CASE TUNER_PRESET06:
    {
    SEND_COMMAND dvARCAM, 'SET BAUD 19200,N,8,1'
    //send_string dvARCAM, Preset06
    }
    CASE TUNER_PRESET07:
    {
    send_string dvARCAM, Preset07
    }
    CASE TUNER_PRESET08:
    {
    send_string dvARCAM, Preset08
    }
    CASE TUNER_PRESET09:
    {
    send_string dvARCAM, Preset09
    }
    CASE TUNER_PRESET10:
    {
    send_string dvARCAM, Preset10
    }

    } // END OF - SWITCH
    } // END OF - PUSH

    } // END OF - button event MainSetup


    DATA_EVENT[dvARCAM]
    {


    COMMAND:
    {
    SEND_STRING dvDebug,"'ARCAM COMMAND'"
    }
    ONLINE :
    {
    SEND_COMMAND dvARCAM, 'SET BAUD 19200,N,8,1'
    SEND_STRING dvDebug,"'ARCAM ONLINE'"
    }
    STRING:
    {
    SEND_STRING dvDebug,"'ARCAM STRING'"
    }

    }

    (***********************************************************)
    (* THE ACTUAL PROGRAM GOES BELOW *)
    (***********************************************************)
    DEFINE_PROGRAM

    (***********************************************************)
    (* END OF PROGRAM *)
    (* DO NOT PUT ANY CODE BELOW THIS COMMENT *)
    (***********************************************************)

    DEFINE_START

    (* Initialize Devices *)


    SEND_COMMAND dvARCAM, 'SET BAUD 19200,N,8,1'



    Thanks for any help

    Ady
  • Options
    DHawthorneDHawthorne Posts: 4,584
    You are not sending HEX values, you are sending the ASCII equivalents.

    For example:

    Preset01 = '$21$13$01$01$0D'

    The single quotes make it ASCII. I'm not certain how to do this in the DEFINE_CONSTANTS section; I would do it in DEFINE_VARIABLES as:

    CONSTANT CHAR Preset01[] = {$21,$13,$01,$01,$0D}

    This will store each string by the HEX value, which I am presuming your protocol requires. If it really does what the ASCII encoding of the HEX, well, never mind :).
  • Options
    adysadys Posts: 395
    OUCH!!!

    :)

    I was debugging all day cause I send wrong values???

    I suspect the values, but I tried different version with no sucess, but not inside variables.

    Why does the notification windows shows the same?


    Thanks a lot, I will check it asap on the morning



    Ady
  • Options
    yuriyuri Posts: 861
    adys wrote:
    OUCH!!!

    :)

    I was debugging all day cause I send wrong values???

    I suspect the values, but I tried different version with no sucess, but not inside variables.

    Why does the notification windows shows the same?


    Thanks a lot, I will check it asap on the morning



    Ady

    it's strange that the notification window showed '!' instead of $21

    It does that when it's sending out "real" hex strings, but since you were sending out ASCII strings i'm really curious what's happening.
    Did you get the '!' when sending from Terminal window or from your program?
  • Options
    Joe HebertJoe Hebert Posts: 2,159
    yuri wrote:
    it's strange that the notification window showed '!' instead of $21
    The notifications window will always show ASCII characters when it can and if it's unprintable then it will show the 2 digit hex code.

    It would be a nice option to have it display all hex if desired. Feature request?...
  • Options
    GSLogicGSLogic Posts: 562
    When you're sending Hex: Power_button[] = { $21$00$01$01$0D }

    Just thought I'd give you another idea.
    Try this in your code, it is much easier to read and faster to code$$$
    DEFINE_EVENT
    
    BUTTON_EVENT[dvTPStudyRoom, nTPTunerBtns]
    {
      PUSH:
      {
        STACK_VAR INTEGER nBtnIndex
        nBtnIndex = GET_LAST(nTPTunerBtns)
    
        if(nBtnIndex == 1)
          send_string dvARCAM, "$21$00$01$, nBtnIndex  ,$0D"    //power command
        else
          send_string dvARCAM, "$21$13$01$, (nBtnIndex-1)  ,$0D"    //all others
      }
    }
    
  • Options
    The port your Arcam is on may never get set to the correct baud rate. Move your "SET BAUD" commands OUT of define_start and put them in DATA_EVENT -> ONLINE: handlers. You are more than likely asking that com port to go to 19.2k before it has come online, so when it actually does appear, it stays at whatever it was at previously - probably 9600.

    - Chip
  • Options
    adysadys Posts: 395
    yuri wrote:
    it's strange that the notification window showed '!' instead of $21

    It does that when it's sending out "real" hex strings, but since you were sending out ASCII strings i'm really curious what's happening.
    Did you get the '!' when sending from Terminal window or from your program?

    From the telnet ( you can see it in the attached picture at the begining of the thread)
  • Options
    adysadys Posts: 395
    Chip Moody wrote:
    The port your Arcam is on may never get set to the correct baud rate. Move your "SET BAUD" commands OUT of define_start and put them in DATA_EVENT -> ONLINE: handlers. You are more than likely asking that com port to go to 19.2k before it has come online, so when it actually does appear, it stays at whatever it was at previously - probably 9600.

    - Chip

    You can see that I am listening to the online event too, and its never gets there.
    when the arcam device up its sends STRING data event and not online...

    is this is normal for devices or am I doing somthing wrong?
  • Options
    DHawthorneDHawthorne Posts: 4,584
    Hardware devices built into the controller chassis (serial, IR, relay, and IO ports) generate an ONLINE event once they start talking to the master, and not again unless the chassis is rebooted or the system gets restarted. In most cases, it happens just after DEFINE_START runs. Unless you connect to the master very quickly after a restart, you aren't likely to see these ONLINE events happen, they are already done.
  • Options
    I only saw the SET_BAUD commands you have in DEFINE_START - not the ones in the module under DATA_EVENT ONLINE:.

    Since that online event happens shortly after the processor reboots, you're probably just not reconnecting to the master in time to see the "ARCAM ONLINE" message...

    - Chip

    adys wrote:
    You can see that I am listening to the online event too, and its never gets there.
    when the arcam device up its sends STRING data event and not online...

    is this is normal for devices or am I doing somthing wrong?
  • Options
    adysadys Posts: 395
    I see

    thanks
Sign In or Register to comment.