Home AMX User Forum AMX Control Products

BSS function checksum not work

Hello every one source code below for control BSS but I don't know why "DEFINE_FUNCTION char fkchecksum (char sBuffer[])" not working. it return value = 0 every time. Please kindly advice me.

DEFINE_FUNCTION char fkchecksum (char sBuffer[])
{
stack_var integer i;
stack_var char ckSum;

for(i=1;i<=length_array(sBuffer);i++);  
   {
     ckSum = ckSum ^ sBuffer[i] ;   
   }

return  ckSum;

}
BUTTON_EVENT[dvTP_Audio,1]
{
hold[1,repeat]:
{
if(iVolume<100)
{
iVolume = iVolume+1

Vcmd ="$8D,$00,$01,$1B,$83,$00,$01,$00,$00,$00,iVolume,$00,$00";

checksum = fkchecksum(Vcmd)

 send_string dvBSSAudio,"STX,Vcmd,$00,iVolume,$00,$00,checksum,EXT"     
 send_level dvTP_Audio,4,iVolume;

  } 
 }     

}

Comments

  • richardhermanrichardherman Posts: 401
    edited September 2021

    Remove the ';' behind the 'for' loop in the fkchecksum function:

    for(i=1;i<=length_array(sBuffer);i++) 
       {
         ckSum = ckSum ^ sBuffer[i] ;   
       }
    

    You can leave out the semicolons (;) all together. They are optional, not needed.

    Good luck!

  • Thank you
    I leave out all semicolon but still not work

  • I did a quick test and it works for me. That is, the checksum was '0' with the semicolon in place and a value is returned otherwise. What is not working?

  • Is the checksum function not working? Or is the control string not working? If it's the latter, are you doing byte substitution to deal with reserved characters? Could you show us more of your code?
  • PROGRAM_NAME='NX2200 Chatrium Ballroom'

    INCLUDE 'SNAPI.axi'

    (***********************************************************)
    (* DEVICE NUMBER DEFINITIONS GO BELOW *)
    (***********************************************************)
    DEFINE_DEVICE

    dvVideoLED = 50001:1:0
    dvVideoProj1 = 50002:1:0
    dvVideoProj2 = 50003:1:0
    dvAudioLED = 8001:1:0
    dvAudioProj1 = 8002:1:0
    dvAudioProj2 = 8002:1:0
    dvBSSAudio = 0:3:0
    dvVideoSwitcher = 0:2:0
    dvProj1 = 5001:1:0
    dvProj2 = 5001:2:0
    dvRelay = 5001:21:0

    dvIPad = 11002:1:0
    dvTP = 11001:1:0

    dvIPAD_VideoSwitcher = 11002:21:0
    dvIPAD_Proj = 11002:22:0
    dvIPAD_Audio = 11002:24:0

    dvTP_Mode = 11001:20:0
    dvTP_VideoSwitcher = 11001:21:0
    dvTP_Proj = 11001:22:0
    dvTP_Audio = 11001:24:0

    DEFINE_COMBINE (dvTP,dvIPad)
    DEFINE_COMBINE (dvTP_VideoSwitcher ,dvIPAD_VideoSwitcher)
    DEFINE_COMBINE (dvTP_Proj ,dvIPAD_Proj)
    DEFINE_COMBINE (dvTP_Audio ,dvIPAD_Audio)

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

    DEFINE_CONSTANT
    DEVICE_NODE_ID = '0x0001' // Node ID/Device ID from Audio Architect
    DEVICE_IP_ADDR = '10.35.95.76'

    STX = $02
    EXT = $03

    // Projector Screen
    SCREEN_UP = 7
    SCREEN_STOP = 8
    SCREEN_DOWN = 9

    // Projecor command
    PROJ_PWR_ON = "'PWR ON',$0D"
    PROJ_PWR_OFF = "'PWR OFF',$0D"
    PROJ_SOURCE1 = "'SOURCE 31',$0D"

    PROJ_MUTE_ON = "'MUTE ON',$0D"
    PROJ_MUTE_OFF = "'PMUTE OFF',$0D"

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

    DEFINE_TYPE

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

    iVideoOutput
    iVolume
    char
    sendtoBSS[200]
    Vcmd [20]
    checksum[20]

    (***********************************************************)
    (* LATCHING DEFINITIONS GO BELOW )
    (***********************************************************)
    DEFINE_LATCHING
    DEFINE_CALL 'SEND TO PROJ'(CHAR CMD[20])
    {
    SEND_STRING dvProj1,"CMD,13"
    SEND_STRING dvProj2,"CMD,13"
    }
    (***********************************************************)
    (
    MUTUALLY EXCLUSIVE DEFINITIONS GO BELOW *)
    (***********************************************************)
    DEFINE_MUTUALLY_EXCLUSIVE

    ([dvRelay,1],[dvRelay,2])
    ([dvRelay,3],[dvRelay,4])

    (***********************************************************)
    (* SUBROUTINE/FUNCTION DEFINITIONS GO BELOW *)
    (***********************************************************)

    DEFINE_FUNCTION char fkchecksum (char sBuffer[])
    {
    stack_var integer i
    stack_var char ckSum

    for(i=1;i<=length_array(sBuffer);i++)  
       {
         ckSum = ckSum BXOR sBuffer[i]   
       }
    
    return  ckSum
    

    }

    (* EXAMPLE: DEFINE_FUNCTION () )
    (
    EXAMPLE: DEFINE_CALL '' () *)

    (***********************************************************)
    (* STARTUP CODE GOES BELOW )
    (***********************************************************)
    DEFINE_START
    IP_CLIENT_OPEN(dvVideoSwitcher.PORT,'192.168.1.50',23,1)
    IP_CLIENT_OPEN(dvBSSAudio.PORT,'192.168.1.143',1023,1)
    (***********************************************************)
    (
    THE EVENTS GO BELOW *)
    (***********************************************************)

    DEFINE_EVENT

    data_event[dvProj1]
    {
    online:
    {
    send_command DATA.DEVICE,"'SET BAUD 9600,N,8,1 485 DISABLE'"
    }
    }
    data_event[dvProj2]
    {
    online:
    {
    send_command DATA.DEVICE,"'SET BAUD 9600,N,8,1 485 DISABLE'"
    }
    }

    data_event[dvBSSAudio]
    {
    online:
    {
    send_string 0," 'online: client'"
    }
    offline:
    {
    send_string 0," 'offline: client'"
    }
    string:
    {
    send_string 0, "'string: client = ',Data.TEXT"
    }
    }
    data_event[dvVideoSwitcher]
    {
    online:
    {
    send_string 0," 'online: client'"
    }
    offline:
    {
    send_string 0," 'offline: client'"
    }
    string:
    {
    send_string 0, "'string: client = ',Data.TEXT"
    }
    }

    BUTTON_EVENT[dvTP_Audio,1]
    {
    hold[1,repeat]:
    {
    if(iVolume<100)
    {
    iVolume = iVolume+1

    Vcmd ="$8D,$00,$01,$1B,$83,$00,$01,$00,$00,$00,iVolume,$00,$00"

    checksum =fkchecksum(Vcmd)

     send_string dvBSSAudio,"STX,Vcmd,$00,iVolume,$00,$00,checksum,EXT"     
     send_level dvTP_Audio,4,iVolume
    
      } 
     }     
    

    }
    BUTTON_EVENT[dvTP_Audio,2]
    {
    hold[1,repeat]:
    {
    if(0<iVolume )
    {
    iVolume = iVolume - 1

    Vcmd ="$8D,$00,$01,$1B,$83,$00,$01,$00,$00,$00,iVolume,$00,$00"
    

    checksum =fkchecksum(Vcmd)

     send_string dvBSSAudio,"STX,Vcmd,$00,iVolume,$00,$00,checksum,EXT"     
     send_level dvTP_Audio,4,iVolume
     sendtoBSS = "STX,Vcmd,$00,iVolume,$00,$00,checksum,EXT"  
     }     
    

    }
    }

    BUTTON_EVENT[dvTP_Proj,0]
    {
    push:
    {
    to[dvTP_Proj,button.input.channel];
    }
    }

    DEFINE_PROGRAM

  • You don't tell us whether the checksum function now returns a value, I will assume it does.

    As ernestmusseriii already mentioned, this won't work (reliably) anyway. The Soundweb protocol asks for character substitutions: https://bssaudio.com/en/site_elements/soundweb-london-third-party-control-application-guide
    last page.

    Also, you seem to open the IP connection to the Soundweb device just once and never check if it's (still) open before you send anything. I _think _the device won't close the connection on it's own, but still.

    Good luck.

  • [Deleted User][Deleted User] Harman Integrated Technologies Group (ITG) Posts: 0

    Or you could just use the BSS module found in InConcert....

  • @HARMAN_Chris said:
    Or you could just use the BSS module found in InConcert....

    Hi Chris,

    Have there been any recent revisions to this module? I used it a few years ago and it was slow and it doesn't control all of the processing object available in the Soundweb london. I ended up having to use the PassThrough portion of the module to control audio matrix mixers which is not a very elegant solution. I stopped using it because of all the little complications I ran into. I ended up using the old BSS .axs file as a base and building my own file for subsequent BSS systems.

  • Hello Chris and every one
    Kindy allow me to expand. I had little experience with AMX Programming, I was also confused by the use of modules. I try to use easy checksum function by return value and then plus with BSS Command sent to BSS but the value return " 0 " every time.

    Now I try to write shot code as below which checksum by plus string. I think it should not be "0" but it has still return " 0 " .

    PROGRAM_NAME='checeksum'
    DEFINE_DEVICE
    dvTP_BSS = 11001:24:0
    DEFINE_VARIABLE
    CHAR
    checksum[20]
    Vcmd[20]
    INTEGER
    iVolume

    DEFINE_FUNCTION char fnChecksum (char sbuffer[20])
    {

    stack_var integer i
    stack_var char ckSum
    for (i=1;i<=length_string(sbuffer);i++)
    {
    ckSum = ckSum+sbuffer[i]
    }
    return ckSum
    }
    DEFINE_EVENT
    BUTTON_EVENT [dvTP_BSS,1]
    {
    PUSH:
    {
    Vcmd = "$8D,$67,$59,$1B,$83,$01,$04,$60"
    checksum = fnChecksum(Vcmd)
    }
    }

    I have a picture which crop screen when the program running but I don't know how to attach in this post..
    kindly help me please
    thank you every

  • [Deleted User][Deleted User] Harman Integrated Technologies Group (ITG) Posts: 0

    @ernestmusseriii said:
    Have there been any recent revisions to this module? I used it a few years ago and it was slow and it doesn't control all of the processing object available in the Soundweb london.

    Ernest, the latest version is quite extensible. You effectively subscribe to anything you care about and it is full featured to my knowledge. You should review the implementation guide to see if it meets your needs.

  • [Deleted User][Deleted User] Harman Integrated Technologies Group (ITG) Posts: 0

    @sujit said:

    I had little experience with AMX Programming, I was also confused by the use of modules.

    I would highly highly recommend reviewing the online training content for AMX Programmers. We have documented both the Level 1 and Level 2 training courses into full video series. This covers 10 days of in-person training and explains how to leverage modules in your projects.

    If you do not have time to complete the training course, you should engage technical support and ask them to remote into your PC and walk through the coding issue you are experiencing. The function always returning a 0 is likely a simple item to resolve because of the narrow scope of investigation.

  • @sujit said:
    Hello Chris and every one
    Kindy allow me to expand. I had little experience with AMX Programming, I was also confused by the use of modules. I try to use easy checksum function by return value and then plus with BSS Command sent to BSS but the value return " 0 " every time.

    Now I try to write shot code as below which checksum by plus string. I think it should not be "0" but it has still return " 0 " .

    PROGRAM_NAME='checeksum'
    DEFINE_DEVICE
    dvTP_BSS = 11001:24:0
    DEFINE_VARIABLE
    CHAR
    checksum[20]
    Vcmd[20]
    INTEGER
    iVolume

    DEFINE_FUNCTION char fnChecksum (char sbuffer[20])
    {

    stack_var integer i
    stack_var char ckSum
    for (i=1;i<=length_string(sbuffer);i++)
    {
    ckSum = ckSum+sbuffer[i]
    }
    return ckSum
    }
    DEFINE_EVENT
    BUTTON_EVENT [dvTP_BSS,1]
    {
    PUSH:
    {
    Vcmd = "$8D,$67,$59,$1B,$83,$01,$04,$60"
    checksum = fnChecksum(Vcmd)
    }
    }

    I have a picture which crop screen when the program running but I don't know how to attach in this post..
    kindly help me please
    thank you every

    Like I said, I did a quick test with your code. It DID return a zero when the ; was behind the for loop (expected).
    With the semicolon removed it definitely returns a value. Not sure what you are doing different than I did.
    But the whole thing still wont work 'as is'. at a minimum you need to do character substitutions like we mentioned above.

Sign In or Register to comment.