Home AMX User Forum AMX General Discussion

Brain dead day

Hello everyone.
I am trying to program a Sanyo XP-41 projector. I have my AXI file and source code that works fine. (So why did I say I want to program this projector?) I want to make the AXI code more standard with my other code, thus making it easier to swap out projectors without changing the soucre code.
The Sanyo uses ASCII code and a 'CR' command to execute a command.ie 'C00'(power on?) command would look like this in my existing code


I want to be able to lose the ",CR" so it matches my other rooms code that looks like this:


looks simple but when I try to combine the 'CRO' and 'CR' commands they don't work. I have tried different configurations and locations but no go.
Samples of what I have tried:


VOLATILE PROJ_ON[14] ={"'C00',CR"}

VOLATILE PROJ_ON[14] ={"'C00','CR'"}


VOLATILE PROJ_ON[14] ={'C00','CR'}

Anyone tell me what config. I've missed or where to go :confused:


  • dchristodchristo Posts: 177
    Initializing character arrays in the DEFINE_VARIABLE or CONSTANT sections is a little wacky. Try this:

    VOLATILE PROJ_ON[14] ={'C','0','0','C','R'} // If the 'CR' is an ASCII string


    VOLATILE PROJ_ON[14] = {'C','0','0',$0D} // If the 'CR' is an actual carriage return.

  • frthomasfrthomas Posts: 176
    dchristo wrote:
    VOLATILE PROJ_ON[14] ={'C','0','0','C','R'}

    Better IMHO:

    VOLATILE CHAR PROJ_ON[] ={'C','0','0','C','R'};

    Assign a type and use a ; at the end; clearer and safer.

    Don't assign a length, let the compiler do it for you.

  • Looks to me that
    VOLATILE PROJ_ON[4] ={"'C00',$0D"} is the right way.
    I programmed a lot of sanyo but never use constants in this way.
    I always do the following
    SA_POW_ON = 'C00'

    And in the program: send_string device,"SA_POW_ON,$0D"

    Any way if you don't declare CR=$0D or CR=13 you can't use CR but you must use $0D or 13 instead.

    Good luck
  • Thanks for the input guys. I tried all the combinations that were listed here and finally got it to work using a combination of them. What looked liked it should of worked would not. Like I said I had a working AXI file that worked using the example that Leo gave ( SEND_STRING PROJ,"PROJ_ON,CR" )
    but wanted to modify it to appear like my other projectors that use ( SEND_STRING PROJ,PROJ_ON ) this way I would only have to change AXI files and not the code if I swapped a projector. Thanks everyone.
  • One thing that I do is to use constants to define useful strings, such as the following:


    CHAR PWR_ON = 'C00'
    CHAR PWR_OFF = 'CO1'

    CR = $0D


    TERM = $OD

    Then in your code, you use the following:




    In this way, the string terminator (TERM) can be anything (even possibly a null-string, although I haven't tried that) and PWR_ON can be any single byte or string value.

    Hope this helps.

    Sheldon Samuels
  • Thomas,
    I did a little test for you and to only way i get it worked is like this


    PROJ_ON[]={$43,$30,$30,$0D} // HEX FOR 'C00',$0D


    Give it a try
    Good luck
  • Thanks for trying out some code. I took a XP-41 off the shelf yesterday and used it to get the code to work. I was able to keep the ASCII code and get everything working but had to change the spacing. I found It odd that the projector wouldn't work when I added the '$0D' to the end of 'C00' until I spaced it all out like this:
    VOLATILE CHAR PROJ_ON[] ={'C','0','0',$0D}

    VOLATILE CHAR PROJ_ON[] ={'C00',$0D}

    It doesn't make alot of sense to me why I had to separate the 'C00' just because I added $0D but who am I to ask as long as the code looks the way I want it to and it works.
  • DHawthorneDHawthorne Posts: 4,584

    VOLATILE CHAR PROJ_ON[] ={'C00',$0D}

    It doesn't make alot of sense to me why I had to separate the 'C00' just because I added $0D but who am I to ask as long as the code looks the way I want it to and it works.
    I think it's because you can't mix single elements in a CHAR array with a string without using double quotes, and you can't use double quotes in an initializer. If you did this: VOLATILE CHAR PROJ_ON[] ={'C', '0', '0', $0D}, I bet it would work, or if you did this:


    // ...later in code, startup maybe

    PROJ_ON = "'C00',$0D"
  • DHawthorneDHawthorne Posts: 4,584
    Bah, read it too fast, you did do it as per my first suggestion. But I think that's the reason - mixed syntax forms.
  • frthomasfrthomas Posts: 176
    DHawthorne wrote:
    If you did this: VOLATILE CHAR PROJ_ON[] ={'C', '0', '0', $0D}, I bet it would work

    Right, he did it and it worked and he tells us all about it above... :-)

    And you figured it all yourself before I could post that and now I can't seem to find a way to delete the message :(
  • This is almost identical to another thread going on somewhere else on this board... :) The "letter of the law" is in tech note 531, which explains (pretty much what has already been echoed here) the rules for declaring string constants in NetLinx, which - IMHO - is kinda wonky. :)

    For strings like these, I just do 'em as variables so I can still use double quotes & all... If it's an array, I define 'em in DEFINE_START.

    Just to be old fashioned...

    - Chip
  • If you take a look inside some of AMX's modules, you will find definitions as simple as what I posted:


    CHAR PWR_ON = 'C00'
    CHAR PWR_OFF = 'CO1'

    And they work. I can't explain why. I haven't done all that much of this myself. But I do sometimes set up room names as follows:

    CHAR RmNames[][20] =

    as either variables or constants. I'm not always consistent in why I use one or the other. But either way, they work. Then I can recall a name simply by using a pointer to the array, like RmName[3] (to get 'Name3').

    For what it's worth.
Sign In or Register to comment.