HomeWorksQS DbXmlInfo.xml file
vining
Posts: 4,368
I can pull the XML file from a browser but for the life of me I can't get any return in my code.
after a modest startup delay I call:
And when I get my online_event I call:
I get nothing in my string_event handler.
All I debug in diagnostics is:
Some times I do also get an ip_error for an invalid port. I've changed the port several time but no other DEV on this master uses any of the numbers I've tried.
The gets strings are exactly what I've seen in WireShark intercepts. I know I'm real rusty but WTF? I'm using an NX processor too which I've played with a few years ago to do some testing and comparisons to NI's.
Anyone got a working code sample to share for pulling the XML file off a QS processor?
#EDIT. FYI, I'm using a different dev port to pull the XML file from my telnet dev port for control and queries.
after a modest startup delay I call:
DEFINE_FUNCTION fnLUTRON_Connect_XML() { fnLUTRON_DeBug("'LUTRON ###############################################:DEBUG<',ITOA(__LINE__),'>'"); fnLUTRON_DeBug("'LUTRON AMX IS OPENING XML CONNECTION :DEBUG<',ITOA(__LINE__),'>'"); fnLUTRON_DeBug("'LUTRON ###############################################:DEBUG<',ITOA(__LINE__),'>'"); //CLEAR_BUFFER cLutron_XML; IP_Client_Open(dvLUTRON_XML.port,LUT_IP_ADDRESS,80,IP_TCP); RETURN; }
And when I get my online_event I call:
DEFINE_FUNCTION fnLutron_GetXML() {//192.168.1.33/DbXmlInfo.xml fnLUTRON_DeBug("'LUTRON ###############################################:DEBUG<',ITOA(__LINE__),'>'"); fnLUTRON_DeBug("'LUTRON ATTEMPTING TO GET XML :DEBUG<',ITOA(__LINE__),'>'"); fnLUTRON_DeBug("'LUTRON ###############################################:DEBUG<',ITOA(__LINE__),'>'"); SEND_STRING dvLutron_XML,"'GET /DbXmlInfo.xml HTTP/1.1',STR_CRLF"; SEND_STRING dvLutron_XML,"'Accept: text/html, application/xhtml+xml, image/jxr, */*',STR_CRLF"; SEND_STRING dvLutron_XML,"'Accept-Language: en-US',STR_CRLF"; SEND_STRING dvLutron_XML,"'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko',STR_CRLF"; SEND_STRING dvLutron_XML,"'Accept-Encoding: gzip, deflate',STR_CRLF"; SEND_STRING dvLutron_XML,"'Host: ',LUT_IP_ADDRESS,STR_CRLF"; SEND_STRING dvLutron_XML,"'If-Modified-Since: ',sMyTime.cWebCurDateTime,STR_CRLF"; SEND_STRING dvLutron_XML,"'Connection: Keep-Alive',STR_CRLF"; SEND_STRING dvLutron_XML,"STR_CRLF"; }
I get nothing in my string_event handler.
All I debug in diagnostics is:
Line 2894 2018-04-20 (11:29:34):: LUTRON AXI DEBUG (1): LUTRON ###############################################:DEBUG<1104> Line 2895 2018-04-20 (11:29:34):: LUTRON AXI DEBUG (1): LUTRON AMX IS OPENING XML CONNECTION :DEBUG<1105> Line 2896 2018-04-20 (11:29:34):: LUTRON AXI DEBUG (1): LUTRON ###############################################:DEBUG<1106> Line 2897 2018-04-20 (11:29:34):: CIpEvent::OnLine 0:13:2 Line 2898 2018-04-20 (11:29:34):: LUTRON AXI DEBUG (1): LUTRON ###############################################:DEBUG<2749> Line 2899 2018-04-20 (11:29:34):: LUTRON AXI DEBUG (1): LUTRON GET XML ONLINE :DEBUG<2750> Line 2900 2018-04-20 (11:29:34):: LUTRON AXI DEBUG (1): LUTRON ###############################################:DEBUG<2751> Line 2901 2018-04-20 (11:29:34):: LUTRON AXI DEBUG (1): LUTRON ###############################################:DEBUG<1576> Line 2902 2018-04-20 (11:29:34):: LUTRON AXI DEBUG (1): LUTRON ATTEMPTING TO GET XML :DEBUG<1577> Line 2903 2018-04-20 (11:29:34):: LUTRON AXI DEBUG (1): LUTRON ###############################################:DEBUG<1578> Line 2904 2018-04-20 (11:29:34):: CIpEvent::OffLine 0:13:2 Line 2905 2018-04-20 (11:29:34):: LUTRON AXI DEBUG (1): LUTRON ###############################################:DEBUG<2756> Line 2906 2018-04-20 (11:29:34):: LUTRON AXI DEBUG (1): LUTRON GET XML OFFLINE :DEBUG<2757> Line 2907 2018-04-20 (11:29:34):: LUTRON AXI DEBUG (1): LUTRON ###############################################:DEBUG<2758>
Some times I do also get an ip_error for an invalid port. I've changed the port several time but no other DEV on this master uses any of the numbers I've tried.
The gets strings are exactly what I've seen in WireShark intercepts. I know I'm real rusty but WTF? I'm using an NX processor too which I've played with a few years ago to do some testing and comparisons to NI's.
Anyone got a working code sample to share for pulling the XML file off a QS processor?
#EDIT. FYI, I'm using a different dev port to pull the XML file from my telnet dev port for control and queries.
0
Comments
SEND_STRING dvLutron_XML,"'GET /DbXmlInfo.xml HTTP/1.1',STR_CRLF,'Accept: text/html, application/xhtml+xml, image/jxr, */*',STR_CRLF,'Accept-Language: en-US',STR_CRLF,'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko',STR_CRLF,'Accept-Encoding: gzip, deflate',STR_CRLF,'Host: ',LUT_IP_ADDRESS,STR_CRLF,'If-Modified-Since: ',sMyTime.cWebCurDateTime,STR_CRLF,'Connection: Keep-Alive',STR_CRLF,STR_CRLF";
Now I should port this over to an NI processor and try both methods again just to see if this is something peculiar to the NX processor or maybe just a Lutron quirk the way it handles incoming strings. I can see it wanting everything smaller then a single MTU being sent in a single segment and not broken up into multiple RX events.
That?s probably what I?ll do to keep it more readable and looking more like my WireShark intercepts.
What eventually seemed to work was I took the large meassages and broke them into consistent 2K chunks and then, of courese, the last chunk being the remainder of whatever size under 2K.
Each 2K chunk was sent into the send_string at that size. I never really figured out if it had to do with the max string size within the Netlinx interpreter or the masx packet size by IP. After all, there are several methods in the IP layer to send large packets that work quite well. That doens' mean the AMX firmware is using them.
All this to say, for really large messages, I still use the 2K method and haven not run into any isses since. But don't aske my why it works. I do not know.
That's pretty much what I ended up doing and after thinking more about it if the string is under a single MTU (1500 less header crap) it really should be sent in a single frame.
2k is an AMX limit or something, I can't remember but an Ethernet frame is much less unless its jumbo. The normal MTU is 1500 and that allows for some header crap but it's safer to stay below that a bit. I believe when I was watching the Lutorn responses in WireShark they were sending 1024 byte frames.
I found this in a quick google:
The original Ethernet IEEE 802.3 standard defined the minimum Ethernet frame size as 64 bytes and the maximum as 1518 bytes. The maximum was later increased to 1522 bytes to allow for VLAN tagging. The minimum size of an Ethernet frame that carries an ICMP packet is 74 bytes.
After looking at this I never even considered a minimum size?
LIke you said who knows how AMX is handling this under the hood, might be best to let it manage the segmenting or at least make sure you're under the now 1522 bytes max. LIke you I did this based on a 1500 or 1492 MTU on a few programs but who knows if it helped or hurt? Can't think of what I was talking too that needed that much data. Actually, must be my daily email logs that are sent to my office master, that I would have segmented into frames.
Paul
Yes, this is true. I was referring more to the outgoing messages from the AMX master. When I Wiresharked (is that a word???) the traffic I seemed to see that the AMX box would arbitrarily seem to sometimes break up a large message into chunkcs by terminating the packed with the end-of-packet block and then restart another new packet right where it left off. As I said, I never really spent much time sussing out the behavior. Sometimes big packages (as you say - up to 16K) would come through just fine.
I didn't mess iwth it much beyond figuring out that 2K seemed to always work well. I figured it was the usual Netlinx limit going out as well as coming back in.
TCP is a prety forgiving protocol as it turns out. I once wrote a little routine in Netlinx trying to fake a png message from the Netlinx layer. I kinda got it to work on a few devices. My method was to write a hex string that started off with the container that would end the first message packet being currently sent out by the netlinx master. then I immediately added the entire packet for a ping message. And then finally the beginning packet of a third TCP mesage which would end just prior to the actual end-of-tcp message generated by the netlinx master. It actually worked on some devices. Obviously the three messages coming at the other device would be a bit too fast, not allowing the device to repsond, especially since the thrid message would fail. But, it did work.
I would prefer to hold the entire xml file and then start parsing on a completed return so I can parse without assuming everything will be returned in the same order all the time since some protocol mandate randomization. I know a recent Perl update in another device screwed up my code that was set up for a consistent order. Devices that use randomization have to be coded much differently and you really need a complete return before you can start.
Is the a way to hold the entire return so I can then parse using a randomized approach? I do prefer an ordered approach so I can advance my find_string pointer or just remove strings as I go but like I said in the previous post I'd rather not bank on the returns always being in a fixed order since now a days it seems that's a not a reliable method of writing a parsing routine. It's definitely more efficient to do it in order but If I later have to rewrite everything to accommodate randomizing that will suck.
Yes. I use integer arrays longer than that, but to send strings around, I think the 16k cap hasn't changed. My guess is it has to do with the definition in UnicodeLib.axi
Paul
I guess I could add the ability guard against randomization by searching for every possible starting tag on each data event and who ever is lowest but above 0 would be declared the winner then wait for that tags end tag, cross it off the search list and continue. Hopefully they don't repeat in nested objects so I don't have to count beginning and ends to find the actual matching end. That doesn't sound too messy and I'm pretty sure I can stay ahead of the incoming strings so nothing is truncated by the 65534 limit. I wonder where the missing byte went, it should be 65535 but all that will store is 65534
Paul
Paul
I noticed in your concant string function you set your buffer length to 262144, were you actually able to hold that much?
I thought about writing to file and parsing from there and it would normally be a one time deal unless the file date time stamp changed but parsing from a file sounds awkward. It just sems I should ne able to have a var hold at least 1mb worth of data.
Yes I've had char arrays as a large as a megabyte before. I don't think there is any builtin limitation beyond how much memory your controller has.
Paul
I wish AMX engineers still trolled this forum with some insight like the good old days.
Paul