Home AMX User Forum AMX General Discussion

Dynamic Images escape sequences

I am trying to get dynamic images working using the RMF command and it seems to be fine except for paths that contain percent encoding. From what I can gather, since the delimiters for the host/path/file contain '%' (ie: %H, %P etc), if '%' shows up in the string then the command gets confused. At least that is what appears to be happening. If I decode the percent encoding, ie: turn %20 to a space, %26 to &, etc the command works. The problem is the device I am getting the images from uses the & character to delimit the URI. So I can't send a '&' character in the URI, but if I percent encode it to %26, the the RMF command seems to get confused. Surprising that they would have chosen the % character to delimit the RMF command since URLs are often filled with them. Any one seen this behavior and know of a work around? Is there a way to send percent encoded strings to the RMF command? I notice they work in TPD4 but not if I use the RMF command.
Thanks,
Paul

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    Can you post an example that doesn’t work?
  • a_riot42a_riot42 Posts: 1,624
    Joe Hebert wrote: »
    Can you post an example that doesn’t work?

    I did a test with a file with an ampersand in the filename and created a directory with an ampersand in it and the RMF command worked fine, at least pulling the image off the controller itself. So it seems that the command isn't the problem but rather the device receiving the URL doesn't like a naked ampersand, but since I can't get it to work with the ampersand percent encoded, I don't have much choice. Since the device responds with a "404 Not Found" when requesting an image using a URL with spaces or ampersands in it from a browser, I have to assume that the RMF command percent encodes reserved characters in the URL in the background prior to sending the request. Is there a way to see the string that is going from the touch panel to the device to see how the request is formatted? Oddly, in TPD if you hard code the percent encoded string it works fine, but the same string in the RMF command fails and has to be decoded to work unless I am doing something wrong.

    The URL I am given to fetch the image looks like this:

    getaa?u=x-file-cifs%3a%2f%2fComputerName%2fMy%2520Music%2fThomas%2520Dolby%2fAliens%2520Ate%2520My%2520Buick%2f01%2520Key%2520to%2520Her%2520Ferrari.wma&v=1

    As you can see the URL is double percent encoded. Hard coding this into TPD works fine as it does when decoded once to:

    getaa?u=x-file-cifs://ComputerName/My%20Music/Thomas%20Dolby/Aliens%20Ate%20My%20Buick/01%20Key%20to%20Her%20Ferrari.wma&v=1

    However, neither of these will work with the RMF command. To work, the string has to be double percent decoded to this:

    getaa?u=x-file-cifs://ComputerName/My Music/Thomas Dolby/Aliens Ate My Buick/01 Key to Her Ferrari.wma&v=1

    Since the device won't resolve this string in a browser I have to assume the RMF command must percent encode spaces, and other URL reserved characters before doing a request. I guess the RMF command encodes these characters while TPD does not and sends the string along without modifying it.

    So as long as the string is double decoded the RMF command works, unless there is an ampersand in the string like this:

    ^RMF-Q2,%H192.168.1.100%A%Fgetaa?u=x-file-cifs://ComputerName/My Music/Emerson, Lake & Palmer/Works, Vol. 1 Disc 1/05 C''est la Vie.wma

    All other non encoded URLs work except those with an ampersand in them, and the RMF command doesn't seem to like percent encoded strings, at least I haven't been able to get them to work.
    Paul
  • Joe HebertJoe Hebert Posts: 2,159
    What’s the max length of a send_command? I may be recalling incorrectly but I thought I read it was something like 128 characters.

    The send_commands for the examples that you posted that don’t work are over 128 characters.

    Try sending the ^RMF %H and %A in one send_command and then the ^RMF %F as another send_command (and keep it under 128 characters) and see if that makes a difference.
  • ericmedleyericmedley Posts: 4,177
    Joe Hebert wrote: »
    What’s the max length of a send_command?

    this is a good question. You might want to telnet into the panel itself and do a msg on all there and see just what the panel is getting itself.
  • Joe Hebert wrote: »
    What’s the max length of a send_command? I may be recalling incorrectly but I thought I read it was something like 128 characters.

    The send_commands for the examples that you posted that don’t work are over 128 characters.

    Try sending the ^RMF %H and %A in one send_command and then the ^RMF %F as another send_command (and keep it under 128 characters) and see if that makes a difference.

    200 character limit. You'll have the same issue using Google Charts technology as it uses '|' as a separator in the URL. Only solution I know of is to retrieve the image file from code and store it on the local master in the file space pointed to by the dynamic image object on the panel(s). Can be a PITA getting it to work, I encapsulated mine in a module and now use it for almost all dynamic images excluding camera feeds.
  • jjamesjjames Posts: 2,908
    Unicode workaround?

    Couldn't one use unicode to insert all sorts of stuff in your commands to make it usable? I'm thinking things that might get picked up by the master such as pipes, or other stuff ??? (Going out on a limb here.)
  • a_riot42a_riot42 Posts: 1,624
    I am not hitting the send_command character limit as I have other dynamic images working with longer URLs than the ones that contain ampersands. I thought of sending unicode and I couldn't get that to work either. I have also stored the image on the master and retrieved it that way, but with the amount of images involved it isn't practical, and I don't want to be constantly writing to a file on the flash. There has to be a way to make this work. It would be easier if the documentation for the dynamic images command weren't so sparse. Interestingly, there are a couple of clues:

    path '%A<path>' Set Image file path. Set Directory path.

    The path must be a valid HTTP URL minus

    the protocol, host, and filename.

    The only exception to this is the

    inclusion of special escape sequences and

    in the case of the FTP protocol,

    regular expressions.


    file '%F<file>' Set Image name. Full path to the location

    of the file or program that will return

    the resource. The path must be a valid

    HTTP URL minus the protocol and host.

    The only exception to this is the

    inclusion of special escape sequences

    and in the case of the FTP protocol,

    regular expressions.
    '

    And in the notes for the RMF command it says this:

    08/05/03 v2.12.50 -2250_10D_V2_12_50.kit

    -G4 Phase II release.

    -Fixed: ^ GRU, ^GRD, %GU, and %GD.

    -Fixed: ^RAF and ^RMF special escape sequences

    properly handled.



    What are the escape sequences they are talking about? It sounds like exactly what I need but I can't find any documentation other than this and TS doesn't know either.
    Paul
  • snoblesnoble Posts: 35
    Since the % is used in the ^RMF command to specify the embedded code (and there is no length for each field), the % itself must be escaped. So try escaping the % with another %. For example, a space in the URL could be encoded as "%%20". I agree with you on the lack of documentation for this - I'll check with our tech pubs team about adding this information.

    By the way, the special escape sequences that are mentioned in the documentation are the $xx codes that sub the relevant local value (e.g. $DV is replaced with the device number).
  • a_riot42a_riot42 Posts: 1,624
    snoble wrote: »
    Since the % is used in the ^RMF command to specify the embedded code (and there is no length for each field), the % itself must be escaped. So try escaping the % with another %. For example, a space in the URL could be encoded as "%%20". I agree with you on the lack of documentation for this - I'll check with our tech pubs team about adding this information.

    I believe I tried that thinking it might be similar to the apostrophe escape sequence and it didn't work. I will try again to be sure.
    snoble wrote: »
    By the way, the special escape sequences that are mentioned in the documentation are the $xx codes that sub the relevant local value (e.g. $DV is replaced with the device number).

    Not sure what you mean here.
    Paul
  • jjamesjjames Posts: 2,908
    I'm going to go out on a limb and guess that $DV is like the $P command in TPD4. ($P in a text field displays the percentage of a bargraph.)

    I do agree though with needing clarification.
  • snoblesnoble Posts: 35
    To clarify, the special escape sequences that can be used in the ^RMF and ^RAF commands are the same ones that can be used in the Resource Manager in TPD4. They are essentially metadata that can be specified as part of the file name to customize the URL based on their values. Again, you have a valid point on the documentation - I will follow up. Copying from the TPD4 help file:

    Escape Sequences
    The program supports the replacement of any special escape sequences with the corresponding data obtained from the system as outlined in the table below that identifies escape sequences. This occurs for all resources.

    For instance, http://www.amx.com/img.asp?device=$DV would become http://www.amx.com/img.asp?device=10001.

    Sequence Panel Information
    $DV Device Number
    $SY System Number
    $IP IP Address
    $HN Host Name
    $MC Mac Address
    $ID Neuron ID
    $PX X resolution of current panel mode/file
    $PY Y resolution of current panel mode/file
    $ST Current state
    $AC Address code
    $AP Address port
    $CC Channel code
    $CP Channel port
    $LC Level code
    $LP Level port
    $BX X Resolution of Current button
    $BY Y Resolution of Current button
    $BN Name of Button
  • a_riot42a_riot42 Posts: 1,624
    Thanks for the clarification. I am curious what Neuron ID is for.
    Paul
  • PhreaKPhreaK Posts: 966
    a_riot42 wrote: »
    Th I am curious what Neuron ID is for.

    I think neuron's are to do with the way devices refer to each other over ICSP.
  • snoblesnoble Posts: 35
    Sorry, I copied from TPD4 without going through the list - the $ID code is not supported (I'll follow up to get it removed from the list). I went through the rest of the list, and all the other codes are supported in firmware.
Sign In or Register to comment.