Reading a TCP stream

Moderator: Moderator Group

Reading a TCP stream

Postby djrappa » Mon Sep 19, 2016 3:18 am

Please forgive my ignorance here, but interpreting network protocols is certainly not my forte.

I have some new control by web controllers that are monitoring power and cooling to my projectors. By default they output their data over a TCP stream which feeds into a built in hosted web page. What I would like to do is bring these values into widget designer.
Using wireshark I can see the packets being sent. But I'm not really sure what combination of nodes and connections I should be using to get a read out of each of these values. Sample packet below.

You can clearly see each value eg. "insidefronta":26.00 the value that will change is 26.00

Can anyone assist me here?

Thanks


HTTP/1.1 200 OK

Server: CBW

Date: Mon, 19 Sep 2016 00:36:13 GMT

Content-Type: application/json

Transfer-Encoding: chunked

Connection: keep-alive



17b

{"widget1":{"electenca":28.50,"supplyVoltage1":23.84,"insidefronta":26.00,"insidereara":26.00,"outsidea":22.00},"widget2":{"fanreara":0,"fansidea":0},"widget3":{"redled":1,"greenled":1,"encfans":1,"rdnpsua":1,"rdnpsub":1},"widget4":{"currenta":1.0,"currentb":0.2,"currentc":1.2,"voltagea":235.25,"voltageb":235.32,"voltagec":233.43,"psu5va":5.00,"psu5vb":5.00},"time":1474281373}

0
Cheers
Clint Dulieu
Dulio Design
djrappa
 
Posts: 183
Joined: Wed Jul 01, 2009 10:46 am

Re: Reading a TCP stream

Postby Johannes Kuhr » Mon Sep 19, 2016 9:08 am

Hi djrappa,

first of all you need a working TCP connection in your WD to read an incoming TCP stream. You can create this by using the internal TCP Connection tool, as discribed in our helpfile:
http://www.coolux.de/root/downloads/sup ... dconnm.htm

To work with the incoming information, you can use e.g. a TCP input node - if you use the WD Pro version - or you can work with the script language:
http://www.coolux.de/root/downloads/sup ... tcp_in.htm

http://www.coolux.de/root/downloads/sup ... d_list.htm

Hope this helps you a bit to get your needed information.

Best regards
Johannes
Johannes Kuhr
Technical Support, coolux GmbH
Johannes Kuhr
 
Posts: 8
Joined: Thu Aug 11, 2016 8:06 am

Re: Reading a TCP stream

Postby djrappa » Mon Sep 19, 2016 9:22 am

I've established a connection which says the client is connected on port 80 however if I test that connection the stream is just blank.
If I say send a random command to that connection I will see a massive stream of ASCII characters in the test window.

The TCP input node just returns a "0" as its value.

I'm afraid I need a little more information on how to analyze that data I've posted above. Are there working example files of this anywhere?
Cheers
Clint Dulieu
Dulio Design
djrappa
 
Posts: 183
Joined: Wed Jul 01, 2009 10:46 am

Re: Reading a TCP stream

Postby Johannes Kuhr » Mon Sep 19, 2016 10:52 am

Which projector brand and type do you use for your job?
Did you already tried the "Projector Control" node - create node -> input -> devices -> proj. control?

There are several threads in this forum about TCP connection to control projector settings etc. - maybe they are helpful for you.

Best
Johannes
Johannes Kuhr
Technical Support, coolux GmbH
Johannes Kuhr
 
Posts: 8
Joined: Thu Aug 11, 2016 8:06 am

Re: Reading a TCP stream

Postby djrappa » Mon Sep 19, 2016 11:00 am

This is not a projector.
This is a programmable controller (control by web x600) which manages the environmental controls for the sealed enclosures these projectors run in.

Talking to the projectors (Christie Boxer 2k30s) is no problem at all.

There is very little info on how the connection manager and TCP nodes actually deal with with the raw packet data. That's why I have posted the wireshark TCP stream data above.

Hopefully my local distributor can point me in the direction of someone that can get this happening for us.
Cheers
Clint Dulieu
Dulio Design
djrappa
 
Posts: 183
Joined: Wed Jul 01, 2009 10:46 am

Re: Reading a TCP stream

Postby scottywalker » Mon Sep 19, 2016 12:20 pm

I don't know if this will help but in the past when i've struggled to get commands or certain information from wireshark but the application that i'm trying to sniff from has a webinterface i have found that i can usually find the answers on the webinterface.
If you open up the interface in your browser and you right click and choose viewsource you can usually isolate the section of the page that has the info you need and decipher the commands from the source scripts.
scottywalker
 
Posts: 31
Joined: Thu Aug 16, 2012 12:58 pm
Location: Dubai U.A.E

Re: Reading a TCP stream

Postby djrappa » Mon Sep 19, 2016 1:34 pm

What I'm finding is it is the page source from the web interface that is being brought into widget designer, this is obviously useless information.
What I need to work out is how to get that information contained in the packets going out (that I captured in my first post) and bring that into WD instead.

The other option I have is to read the values as modbus TCP, not sure if anyone has setup a modbus connection with WD??
Cheers
Clint Dulieu
Dulio Design
djrappa
 
Posts: 183
Joined: Wed Jul 01, 2009 10:46 am

Re: Reading a TCP stream

Postby chrisr » Mon Sep 19, 2016 2:34 pm

Looking at the stream you provided, I don't see why you couldn't break that out using the TCP Input NODE, which Johannes mentioned.

http://www.coolux.de/root/downloads/sup ... tcp_in.htm

IF you look at the image provided in the online manual (link above), you'll see an area ASCII Start, ASCII Split and ASCII Stop. These three, can help you grab information from a network stream.

Lets Look at this section {"widget1":{"electenca":28.50,"supplyVoltage1" and single out the highlighted area marked in Green

It might look something like
ASCII Start: "electenca":
ASCII Split:
ASCII Stop: ,

This would single out the data 28.50

- AS you have a few different things you are looking for, I would have a TCP Input node for each one.

Good Luck!
Thank You

ChrisR
SurfacePro3 - 2GHz i5 - 4GB ram - Windows 10 Pro - WD Pro 4.7 Rev2500 and WD v6
Sager Laptop - Intel 2.4GHz i7 3630QM - 16GB ram - Windows 7 Pro Svc Pack1 - Offline Manager v6
chrisr
 
Posts: 143
Joined: Tue Jan 26, 2016 10:50 pm

Re: Reading a TCP stream

Postby scottywalker » Mon Sep 19, 2016 2:45 pm

If you're using chrome for the browser you can right click and choose 'inspect'. In the panel that then opens on the right you can select 'network' and then highlight the area in your webinterface and it will show you which commands are being sent with quite a lot more useful information than you get in wireshark.
scottywalker
 
Posts: 31
Joined: Thu Aug 16, 2012 12:58 pm
Location: Dubai U.A.E

Re: Reading a TCP stream

Postby Dennis Kuypers » Mon Sep 19, 2016 9:02 pm

Hey,

Widget Designer has dedicated support for JSON over HTTP using either JsonRequestToVar in conjunction with VGetJsonItem, or JsonRequestItemToVar (when requesting only few items). You probably want to go with the first one. All you need is to know the request URI. Look in wireshark for "GET /some/url?with=params_maybe HTTP/1.1"

Regards
Dennis
Dennis Kuypers
(former Product Developer, Software)
Dennis Kuypers
coolux Germany
 
Posts: 771
Joined: Thu Jul 05, 2012 12:18 pm

Re: Reading a TCP stream

Postby chrisr » Mon Sep 19, 2016 10:55 pm

Dennis, I see that there is JSON support now, was this with Ver2500? Am I reading correctly, that we can make JSON requests via HTTP out to the WWW? Or is this local support within an intranet.
Thank You

ChrisR
SurfacePro3 - 2GHz i5 - 4GB ram - Windows 10 Pro - WD Pro 4.7 Rev2500 and WD v6
Sager Laptop - Intel 2.4GHz i7 3630QM - 16GB ram - Windows 7 Pro Svc Pack1 - Offline Manager v6
chrisr
 
Posts: 143
Joined: Tue Jan 26, 2016 10:50 pm

Re: Reading a TCP stream

Postby djrappa » Tue Sep 20, 2016 12:04 am

Thanks guys for all these suggestions. I will look at them today.
The original issue is I wasn't able to get that original packet I posted coming into WD, hence why I couldn't use the TCP node. All it was sending in was the source code for its webpage.

Being able to support JSon will completely resolve this issue.

The other solution I came up with is to use the Excel node to monitor xml file the controller maintains with all its current parameters.
Cheers
Clint Dulieu
Dulio Design
djrappa
 
Posts: 183
Joined: Wed Jul 01, 2009 10:46 am

Re: Reading a TCP stream

Postby djrappa » Tue Sep 20, 2016 2:23 am

Can you offer any more details on how these JSon commands function as once again they are released but not documented in the online help.

I can return my request as a variable however it contains several values which I need to extract individually. As the text filter nodes are not fully documented either I am having some difficult extracting the numbers out of the text string for use as values in WD.

Thanks
Cheers
Clint Dulieu
Dulio Design
djrappa
 
Posts: 183
Joined: Wed Jul 01, 2009 10:46 am

Re: Reading a TCP stream

Postby Dennis Kuypers » Tue Sep 20, 2016 12:21 pm

Hello,

you have to find out what the URI ist. The crome debugging tools show you all the requests that are made. Once you know this you can use
Code: Select all
JsonRequestToVar,http://10.0.0.1/some?request=uri,status
to request the data. This assumes that a string variable called "status" is available.
The response is like a tree:
Code: Select all
{
   "widget1":
   {
      "electenca":28.50,
      "supplyVoltage1":23.84,
      "insidefronta":26.00,
      "insidereara":26.00,
      "outsidea":22.00
   },
   "widget2":
   {
      "fanreara":0,
      "fansidea":0
   },
   "widget3":
   {
      "redled":1,
      "greenled":1,
      "encfans":1,
      "rdnpsua":1,
      "rdnpsub":1
   },
   "widget4":
   {
      "currenta":1.0,
      "currentb":0.2,
      "currentc":1.2,
      "voltagea":235.25,
      "voltageb":235.32,
      "voltagec":233.43,
      "psu5va":5.00,
      "psu5vb":5.00
   },
   "time":1474281373
}
You basically dig into this by concatenating the keys (in quotes) with dots like so: widget1.insidereara

Create another variable to hold the value. I called it "value" for this example:
Code: Select all
VGetJsonItem,value,widget1.insidereara,status


Now "value" should contain the value "26".

Regards
Dennis
Dennis Kuypers
(former Product Developer, Software)
Dennis Kuypers
coolux Germany
 
Posts: 771
Joined: Thu Jul 05, 2012 12:18 pm

Re: Reading a TCP stream

Postby djrappa » Tue Sep 20, 2016 4:15 pm

Thank you Dennis that explains it perfectly.
The confusion was in the use of and function of the different Json nodes without having a help file for them.

I had a workaround of splitting the original data using text filters which I could determine by trial and error but this is a nice clean solution.

Thanks for your help.
Cheers
Clint Dulieu
Dulio Design
djrappa
 
Posts: 183
Joined: Wed Jul 01, 2009 10:46 am

Next

Return to Widget Designer V4.7

Who is online

Users browsing this forum: No registered users and 28 guests

cron