Home AMX User Forum NetLinx Studio

Trouble concatenating

Scratching my head.

DEFINE_CONSTANT
char strMagicPacketHeader[6] = {$FF,$FF,$FF,$FF,$FF,$FF}

DEFINE_VARIABLE
volatile char strHEXMAC[6]
volatile char strMagicPacket[102]

The following snippet is run in a function
{
strHEXMAC = “$0, $24, $1D, $87, $E2, $F” // This is set elsewhere but shown here for clarity, it is a HEX string not an ASCII string
strMagicPacket = "strMagicPacketHeader, strHEXMAC, strHEXMAC, strHEXMAC, strHEXMAC, strHEXMAC, strHEXMAC, strHEXMAC, strHEXMAC, strHEXMAC, strHEXMAC, strHEXMAC, strHEXMAC, strHEXMAC, strHEXMAC, strHEXMAC, strHEXMAC"
}

After running the code above, strMagicPacket = “$FF,$FF,$FF,$FF,$FF,$FF” and is reported as being only 6 bytes in length!!
Any ideas?

Comments

  • ColzieColzie Posts: 470
    I ran your code and it worked.

    I did have to change the quotes around your strHEXMAC to get it to compile. I'm not sure where it comes from, but sometimes when you copy/paste from MS Word you get quotes that aren't quotes. I don't know that this is your issue, though, since yours obviously compiled.

    I just stuck the concatenation in define_start.

    Must have something to do with the rest of your code. Maybe stick in some send_string 0, 'useful info' to watch as things happen?
  • ericmedleyericmedley Posts: 4,177
    This is totally anecdotal. but...

    You might check to see that A) If you're using the 'relatively' latest version of NS then B) make sure the firmware on the master is the latest. I've noticed that when I've been going back to older projects lately that haven't been touched in over 2 years, I find weird quirks all on a sudden with the serial comm and IP as well.

    Updating the firmware seemed to fix the issue.

    Once again, totally anecdotal disclaimer emphasized.
  • viningvining Posts: 4,368
    If you look at strHEXMAC in debug does it actually hold any lenght or value?

    I know I had an issue doing this once and just couldn't assign my value that way. So I ended up doing the 1 byte at a time appraoch:
         sSqzBox.sPlayer.nRealMAC[1] = $00 ;//,$21,$85,$C2,$31,$17" ;
         sSqzBox.sPlayer.nRealMAC[2] = $21 ;
         sSqzBox.sPlayer.nRealMAC[3] = $85 ;
         sSqzBox.sPlayer.nRealMAC[4] = $C2 ;
         sSqzBox.sPlayer.nRealMAC[5] = $31 ;
         sSqzBox.sPlayer.nRealMAC[6] = $17 ;
    
    I'm alot stupid when it comes to this stuff and since this worked I gave up trying to figure out why.

    Note: I'm using .nRealMac here cuz I also have a nFakeMac which the server uses, otherwise it would just be .nMac
Sign In or Register to comment.