Home AMX User Forum AMXForums Archive Threads AMX Hardware

FILE_WRITE strings w/ =

Has anyone noticed that if you write to file and the string contains a equal sign ( = , decimal 61) the equal will print but the next 2 characters don't and then the remaining characters shift left in their place.

I can live w/o using = or I could pad them w/ extra spaces after each occurrence as sacrificial characters but I'd rather not?

Does anyone know why this happens?

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    vining wrote: »
    Has anyone noticed that if you write to file and the string contains a equal sign ( = , decimal 61) the equal will print but the next 2 characters don't and then the remaining characters shift left in their place.
    I don?t find that to be the case over here. I use equal signs all the time when I FIILE_WRITE to log files and have never had an issue with them.
  • viningvining Posts: 4,368
    Hmmm.... Very interesting! I put some = signs back in the log functions and now they are working. I'll need to play with this some more to replicate what I had previously to figure out what exactly was causing this problem.
  • AuserAuser Posts: 506
    I've noticed similar strange behaviour in string operations which occur inside a switch - case statement before. In my case it was a literal % symbol that was causing the errant behaviour (from an Extron protocol). Sounds like the two could be related. Replacing the switch - case statement with an if - then - else if block was the only way I could resolve it in my case.
  • viningvining Posts: 4,368
    Well I opened my email this morning and the "=" problem was back, then it dawned on me that maybe it wasn't a writing problem but a reading or better yet the way NetLinx handles file attatcments.

    This is from the file attached in my nightly SitRep email:
    <<< 18:00 >>>
    (0000233757) TEST EQUAL SIGN. This =hat, This , This 345
    (0000235782) TEST EQUAL SIGN. This =hat, This , This 345
    (0000237800) TEST EQUAL SIGN. This =hat, This , This 345
    (0000239779) TEST EQUAL SIGN. This =hat, This , This 345
    (0000241855) TEST EQUAL SIGN. This =hat, This , This 345
    (0000243817) TEST EQUAL SIGN. This =hat, This , This 345
    (0000244104) 18:00:29 * SECURITY, PARTITION 1 : DISARMED
    (0000244140) 18:00:29 * SECURITY, ALARM : INTRUSION =FF!
    (0000244156) 18:00:29 * SECURITY, ALARM : FIRE =FF!
    (0000244172) 18:00:29 * SECURITY, ALARM : GAS =FF!
    (0000244189) 18:00:29 * SECURITY, ALARM : AUX =FF!
    (0000244209) 18:00:29 * SECURITY, ALARM : FREEZE =FF!
    (0000244245) 18:00:29 * SECURITY, ALARM : WATER =FF!
    (0000244261) 18:00:29 * SECURITY, ALARM : DURESS =FF!
    (0000244276) 18:00:29 * SECURITY, ALARM : TEMP =FF!
    (0000245430) 18:00:31 * SECURITY, ALARM : INTRUSION =FF!
    (0000245446) 18:00:31 * SECURITY, ALARM : FIRE =FF!
    (0000245484) 18:00:31 * SECURITY, ALARM : GAS =FF!
    (0000245504) 18:00:31 * SECURITY, ALARM : AUX =FF!
    (0000245874) TEST EQUAL SIGN. This =hat, This , This 345
    (0000247585) 18:00:33 * SECURITY, LAST LOG ENTRY : 11/29 17:59 - Armed in mode Disarm  by Structure Works
    (0000247870) TEST EQUAL SIGN. This =hat, This , This 345
    (0000249877) TEST EQUAL SIGN. This =hat, This , This 345
    (0000251903) TEST EQUAL SIGN. This =hat, This , This 345
    (0000253920) TEST EQUAL SIGN. This =hat, This , This 345
    (0000255894) TEST EQUAL SIGN. This =hat, This , This 345
    (0000256020) 18:00:41 * SECURITY, PARTITION 1 : ARMED AWAY
    (0000257470) 18:00:43 * SECURITY, PARTITION 1 : Arming......
    (0000221895) 18:00:07 * HVAC, USER PUSH : Zone : Basement : Increase CoolPoint
    (0000222035) 18:00:07 * HVAC, RESPONSE : Zone : Basement : COOL SP =9
    (0000223698) TEST EQUAL SIGN. This =hat, This , This 345
    (0000224198) 18:00:09 * HVAC, RESPONSE : Zone : Basement : COOL SP =8
    <<< 21:00 >>>
    (0014612837) 22:00:01 * SENT : T-1 HEAT-64 : From VSTAT Program.
    (0014612923) 22:00:01 * HVAC, RESPONSE : Zone : Basement : HEAT SP =4
    (0014613330) 22:00:01 * SENT : T-1 COOL-78 : From VSTAT Program.
    (0014613415) 22:00:01 * HVAC, RESPONSE : Zone : Basement : COOL SP =8
    (0014613824) 22:00:02 * SENT : T-2 HEAT-64 : From VSTAT Program.
    (0014613899) 22:00:02 * HVAC, RESPONSE : Zone : Living Room  : HEAT SP =4
    (0014614318) 22:00:02 * SENT : T-2 COOL-78 : From VSTAT Program.
    (0014614388) 22:00:02 * HVAC, RESPONSE : Zone : Living Room  : COOL SP =8
    (0014614814) 22:00:03 * SENT : T-3 HEAT-66 : From VSTAT Program.
    (0014614888) 22:00:03 * HVAC, RESPONSE : Zone : Kitchen : HEAT SP =6
    (0014615308) 22:00:03 * SENT : T-3 COOL-78 : From VSTAT Program.
    (0014615390) 22:00:03 * HVAC, RESPONSE : Zone : Kitchen : COOL SP =8
    (0014615798) 22:00:04 * SENT : T-4 HEAT-66 : From VSTAT Program.
    (0014615883) 22:00:04 * HVAC, RESPONSE : Zone : 2nd FL Bedrooms : HEAT SP =6
    (0014616307) 22:00:04 * SENT : T-4 COOL-78 : From VSTAT Program.
    (0014616382) 22:00:04 * HVAC, RESPONSE : Zone : 2nd FL Bedrooms : COOL SP =8
    (0014616785) 22:00:05 * SENT : T-5 HEAT-66 : From VSTAT Program.
    (0014616853) 22:00:05 * HVAC, RESPONSE : Zone : Master Suite : HEAT SP =6
    (0014617294) 22:00:05 * SENT : T-5 COOL-78 : From VSTAT Program.
    (0014617368) 22:00:05 * HVAC, RESPONSE : Zone : Master Suite : COOL SP =8
    (0014617783) 22:00:06 * SENT : T-6 HEAT-64 : From VSTAT Program.
    (0014617861) 22:00:06 * HVAC, RESPONSE : Zone : 3rd FL Bedrooms : HEAT SP =4
    (0014618282) 22:00:06 * SENT : T-6 COOL-78 : From VSTAT Program.
    (0014618426) 22:00:06 * HVAC, RESPONSE : Zone : 3rd FL Bedrooms : COOL SP =8
    (0014618780) 22:00:07 * SENT : T-7 HEAT-64 : From VSTAT Program.
    (0014618912) 22:00:07 * HVAC, RESPONSE : Zone : 3rd FL Playroom : HEAT SP =4
    (0014619273) 22:00:07 * SENT : T-7 COOL-78 : From VSTAT Program.
    (0014619412) 22:00:07 * HVAC, RESPONSE : Zone : 3rd FL Playroom : COOL SP =8
    (0014619773) 22:00:08 * SENT : T-8 HEAT-64 : From VSTAT Program.
    (0014619895) 22:00:08 * HVAC, RESPONSE : Zone : 3rd FL Spa : HEAT SP =4
    

    You can see that everywhere I have an equal sign the next two characters that follows are missing. In some cases the = sign disappeared too!

    Now if I FTP into the master and open the file directly everything is written correctly.
    <<< 18:00 >>>
    (0000233757) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000235782) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000237800) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000239779) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000241855) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000243817) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000244104) 18:00:29 * SECURITY, PARTITION 1 : DISARMED
    (0000244140) 18:00:29 * SECURITY, ALARM : INTRUSION = OFF!
    (0000244156) 18:00:29 * SECURITY, ALARM : FIRE = OFF!
    (0000244172) 18:00:29 * SECURITY, ALARM : GAS = OFF!
    (0000244189) 18:00:29 * SECURITY, ALARM : AUX = OFF!
    (0000244209) 18:00:29 * SECURITY, ALARM : FREEZE = OFF!
    (0000244245) 18:00:29 * SECURITY, ALARM : WATER = OFF!
    (0000244261) 18:00:29 * SECURITY, ALARM : DURESS = OFF!
    (0000244276) 18:00:29 * SECURITY, ALARM : TEMP = OFF!
    (0000245430) 18:00:31 * SECURITY, ALARM : INTRUSION = OFF!
    (0000245446) 18:00:31 * SECURITY, ALARM : FIRE = OFF!
    (0000245484) 18:00:31 * SECURITY, ALARM : GAS = OFF!
    (0000245504) 18:00:31 * SECURITY, ALARM : AUX = OFF!
    (0000245874) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000247585) 18:00:33 * SECURITY, LAST LOG ENTRY : 11/29 17:59 - Armed in mode Disarm  by Structure Works
    (0000247870) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000249877) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000251903) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000253920) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000255894) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000256020) 18:00:41 * SECURITY, PARTITION 1 : ARMED AWAY
    (0000257470) 18:00:43 * SECURITY, PARTITION 1 : Arming......
    (0000221895) 18:00:07 * HVAC, USER PUSH : Zone : Basement : Increase CoolPoint
    (0000222035) 18:00:07 * HVAC, RESPONSE : Zone : Basement : COOL SP =79
    (0000258022) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000258772) 18:00:44 * SECURITY, ALARM : INTRUSION = OFF!
    (0000258809) 18:00:44 * SECURITY, ALARM : FIRE = OFF!
    (0000258830) 18:00:44 * SECURITY, ALARM : GAS = OFF!
    (0000258846) 18:00:44 * SECURITY, ALARM : AUX = OFF!
    (0000258864) 18:00:44 * SECURITY, ALARM : FREEZE = OFF!
    (0000258956) 18:00:44 * SECURITY, ALARM : WATER = OFF!
    (0000258971) 18:00:44 * SECURITY, ALARM : DURESS = OFF!
    (0000259422) 18:00:45 * SECURITY, LAST LOG ENTRY : 11/29 17:59 - Armed in mode Away mode  by Structure Works
    (0000260036) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000262037) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000264034) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000266032) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000268030) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000270049) TEST EQUAL SIGN. This = That, This=00, This =12345
    (0000272097) TEST EQUAL SIGN. This = That, This=00, This =12345
    <<< 21:00 >>>
    (0014612837) 22:00:01 * SENT : T-1 HEAT-64 : From VSTAT Program.
    (0014612923) 22:00:01 * HVAC, RESPONSE : Zone : Basement : HEAT SP = 64
    (0014613330) 22:00:01 * SENT : T-1 COOL-78 : From VSTAT Program.
    (0014613415) 22:00:01 * HVAC, RESPONSE : Zone : Basement : COOL SP = 78
    (0014613824) 22:00:02 * SENT : T-2 HEAT-64 : From VSTAT Program.
    (0014613899) 22:00:02 * HVAC, RESPONSE : Zone : Living Room  : HEAT SP = 64
    (0014614318) 22:00:02 * SENT : T-2 COOL-78 : From VSTAT Program.
    (0014614388) 22:00:02 * HVAC, RESPONSE : Zone : Living Room  : COOL SP = 78
    (0014614814) 22:00:03 * SENT : T-3 HEAT-66 : From VSTAT Program.
    (0014614888) 22:00:03 * HVAC, RESPONSE : Zone : Kitchen : HEAT SP = 66
    (0014615308) 22:00:03 * SENT : T-3 COOL-78 : From VSTAT Program.
    (0014615390) 22:00:03 * HVAC, RESPONSE : Zone : Kitchen : COOL SP = 78
    (0014615798) 22:00:04 * SENT : T-4 HEAT-66 : From VSTAT Program.
    (0014615883) 22:00:04 * HVAC, RESPONSE : Zone : 2nd FL Bedrooms : HEAT SP = 66
    (0014616307) 22:00:04 * SENT : T-4 COOL-78 : From VSTAT Program.
    (0014616382) 22:00:04 * HVAC, RESPONSE : Zone : 2nd FL Bedrooms : COOL SP = 78
    (0014616785) 22:00:05 * SENT : T-5 HEAT-66 : From VSTAT Program.
    (0014616853) 22:00:05 * HVAC, RESPONSE : Zone : Master Suite : HEAT SP = 66
    (0014617294) 22:00:05 * SENT : T-5 COOL-78 : From VSTAT Program.
    (0014617368) 22:00:05 * HVAC, RESPONSE : Zone : Master Suite : COOL SP = 78
    (0014617783) 22:00:06 * SENT : T-6 HEAT-64 : From VSTAT Program.
    (0014617861) 22:00:06 * HVAC, RESPONSE : Zone : 3rd FL Bedrooms : HEAT SP = 64
    (0014618282) 22:00:06 * SENT : T-6 COOL-78 : From VSTAT Program.
    (0014618426) 22:00:06 * HVAC, RESPONSE : Zone : 3rd FL Bedrooms : COOL SP = 78
    (0014618780) 22:00:07 * SENT : T-7 HEAT-64 : From VSTAT Program.
    (0014618912) 22:00:07 * HVAC, RESPONSE : Zone : 3rd FL Playroom : HEAT SP = 64
    (0014619273) 22:00:07 * SENT : T-7 COOL-78 : From VSTAT Program.
    (0014619412) 22:00:07 * HVAC, RESPONSE : Zone : 3rd FL Playroom : COOL SP = 78
    (0014619773) 22:00:08 * SENT : T-8 HEAT-64 : From VSTAT Program.
    (0014619895) 22:00:08 * HVAC, RESPONSE : Zone : 3rd FL Spa : HEAT SP = 64
    
    Obviously last night when I thought the problem went away I was checking the file directly on the master and not forcing a "send email".
  • jweatherjweather Posts: 320
    What are you using to e-mail the attachment? The problem is occurring either at the AMX code sending the attachment, an intervening mail server, or your mail client. The reason it occurs is that = is a MIME escape code meaning "treat the next two characters as a HEX code". It works similarly to % in URLs or \x in C strings. You can verify this behavior by looking at the first line of your test:

    = T turned into = since the code wasn't valid. =00 disappeared since it turned into a null. =12 turned into unicode character 12 (at least, that's what my browser shows: a little box with 00 12 in it)

    The question is which part of the mail flow actually did the misinterpreting -- is it your AMX code labeling the attachment incorrectly as MIME encoded rather than plain text? Or an intervening mail server reformatting the attachment as if it was MIME encoded? Or your mail client showing you the attachment assuming it was MIME encoded?

    The way to escape an equals sign for ASCII encoding should be obvious -- =3D. Unfortunately, this makes your on-disk version of the file less readable.

    Jeremy
  • viningvining Posts: 4,368
    jweather wrote:
    The reason it occurs is that = is a MIME escape code meaning "treat the next two characters as a HEX code".
    I'm using i!-EquipmentMonitorOut to send the email with attachments and it is set up for MIME. I tried commenting out this section of the code:
     cCmd = "'MIME-Version: 1.0',13,10" 
    SEND_STRING dvSmtpSocket,"cCmd"
    
    But I was still having the same problem.

    It's easier to live with the MIME and the advantages it offers than for me to spend the time to figure out a work around.
    The lines going into the log go through a clean ascii function anyway so I simply modified it to also replace any = signs it finds with a - instead.

    At least I know what the problem is now, thanks for the response!
Sign In or Register to comment.