Ewon TechForum
Providing technical solutions to technical requests


Help needed regarding M2U service
biztech Offline
Junior Member
#1
Hello,

We are trying to use M2U service for one of our customer using eWon devices for their plants, but facing some issue, if some one can help us will be highly appreciated!

Here is the picture,

We have developed our custom web server (NodeJS + restify) to receive eWon data through M2U talk2m service and have configured eWon to use our custom web server by configuring the M2U service in eCatcher, as mentioned here, https://developer.ewon.biz/sites/default/files/m2u_-_users_guide.pdf

Now, eWon can successfully connect to our custom web server but we are missing API reference or set of requests M2U network will make on behalf of eWon to push data to our web server and we are stuck here!

After some trial and error we noticed it makes a GET request, /commandfile.php, to our web server passing eWon fields (which are ticked in eCatcher) but in response it need time stamp of last sync, but we are not sure in which format we should pass this time stamp.

Secondly, we put a static string of time in response for now, and it started making another POST request, /senddatafile.php, which is posting some kind of file data but we are not able to receive it, and guess its failing due to M2U closing the connection, also we are not sure what kind of data it sends to our server and that way we are having hard time guessing the request body to parse.

Any help would be much appreciated, here, like provide some kind of, this, ewon -> M2U -> custom web server, communication guide?

Thanks,
Dhaval
Reply

simon Offline
eWON Support
#2
I think you have configured the M2U URL in the eWON Data management menu, right ?
So, in that case, the eWON Flexy will push its data using the DMBin protocol which is quite difficult to implement and is only disclosed through a NDA.

To make thing easier, I think you should not use the M2U service but rather the DataMailBox for that (https://developer.ewon.biz/content/dmweb-api)
With the DataMailbox, your NodeJS service will have to act as a client and not like a server.
Reply

biztech Offline
Junior Member
#3
(08-02-2017, 12:52 PM)Simon Wrote: I think you have configured the M2U URL in the eWON Data management menu, right ?
So, in that case, the eWON Flexy will push its data using the DMBin protocol which is quite difficult to implement and is only disclosed through a NDA.

To make thing easier, I think you should not use the M2U service but rather the DataMailBox for that (https://developer.ewon.biz/content/dmweb-api)
With the DataMailbox, your NodeJS service will have to act as a client and not like a server.

Oh... i see, thanks for the clarification.

Also, will it be possible to share more info on the NDA part? how can we do it? is it paid service or something?

Our current system is already using data mailbox to poll for new data at some interval, which is in php and but we are upgrading the system, thought M2U will be best option to get the data!

Anyway, thank you, this will help us decide which route to go Smile

- Dhaval
Reply

simon Offline
eWON Support
#4
No, it is not a paid service but it is a quite long process. I would not advise to use that protocol. Indeed even if you manage to get the file, it will be a tar.gz file that will be containing txt files + data binary files that you will have to parse yourself.

If you really want the eWON to push its data to you, it is far simpler to use such a script to get the data in the form of a CSV file :https://techforum.ewon.biz/thread-206.html
Reply

biztech Offline
Junior Member
#5
(08-02-2017, 01:56 PM)Simon Wrote: No, it is not a paid service but it is a quite long process.  I would not advise to use that protocol. Indeed even if you manage to get the file, it will be a tar.gz file that will be containing txt files + data binary files that you will have to parse yourself.

If you really want the eWON to push its data to you, it is far simpler to use such a script to get the data in the form of a CSV file :https://techforum.ewon.biz/thread-206.html


Ok, make sense!! DMWeb API should be a good choice to go with compared to parsing those files then Smile

Will have a look at the script!!

Thank you Simon for the help.

- Dhaval
Reply

biztech Offline
Junior Member
#6
Hi Simon,

One more thing, just to get more info on this!!

What can be the max / min timings for reading / receiving data from Data mailbox and M2U services?

Like, if you use data mailbox, ewon pushed data to DMWeb API at minimum 1 min interval (can it be smaller than this?) and then our app reads the data at 1 minute interval, so that can be min = 1 (best case) and max = 2 (worst case) minutes to get the data into the system, right?

If you use M2U, ewon can push data to M2U at 1 minute interval and the M2U pushes data almost instantly to our server, so it may be slightly greater than 1 min?

Thanks 
Dhaval
Reply

simon Offline
eWON Support
#7
Your question surprises me a bit.
Indeed, if you are interested by the eWON historical logging, 1 or 2 minutes to wait for the data is not much...

Now, maybe what you are looking for is a kind of real-time system ?
Indeed, if you use a HTTP Push method (through M2U or not), it is "faster" since you skip a "hop" in the path which is the Talk2M DataMailbox.

To come back on your question, technically it can be less than one minute in the eWON. The trick is to use script to launch the "DMSYNC" command whenever you want.
The best in your case (depending on the process you monitor) is to trigger it when a Tag value changes (ONCHANGE "TagName", "DMSYNC") and not every 30 sec or something like that. Indeed, if it is a slow process, by pushing every x seconds, you'll probably push nothing many times...
Reply

biztech Offline
Junior Member
#8
(08-02-2017, 07:36 PM)Simon Wrote: Your question surprises me a bit.
Indeed, if you are interested by the eWON historical logging, 1 or 2 minutes to wait for the data is not much...

Now, maybe what you are looking for is a kind of real-time system ?
Indeed, if you use a HTTP Push method (through M2U or not), it is "faster" since you skip a "hop" in the path which is the Talk2M DataMailbox.

To come back on your question, technically it can be less than one minute in the eWON. The trick is to use script to launch the "DMSYNC" command whenever you want.
The best in your case (depending on the process you monitor) is to trigger it when a Tag value changes (ONCHANGE "TagName", "DMSYNC") and not every 30 sec or something like that.  Indeed, if it is a slow process, by pushing every x seconds, you'll probably push nothing many times...

Hi Simon,

Thanks, Indeed, we are looking for the real time values as fast as we can receive!! and your suggestion to use the script to trigger DMSYNC on tag change seems good option, and may be we can poll data mailbox more frequently for Data !!

Also, just came across this link : https://developer.ewon.biz/content/make-...-thingworx, may be that can fit our use case, checking for feasibility Smile

Thanks,
Dhaval
Reply

simon Offline
eWON Support
#9
If you are looking for developing a real time solution, you can maybe mix both.
To get the realtime data, use a push method (push data over HTTP(S) for example).
For the Histo Data, use the datamailbox (at a slow poll rate (Ex : every 30 min)). Good to use it in case communication is interrupted.
Indeed the datamailbox has not been designed to be used as a realtime system (For that purpose, we are considering another kind of solution for the future)
Reply

biztech Offline
Junior Member
#10
(10-02-2017, 03:14 PM)Simon Wrote: If you are looking for developing a real time solution, you can maybe mix both.
To get the realtime data, use a push method (push data over HTTP(S) for example).
For the Histo Data, use the datamailbox (at a slow poll rate (Ex : every 30 min)). Good to use it in case communication is interrupted.
Indeed the datamailbox has not been designed to be used as a realtime system (For that purpose, we are considering another kind of solution for the future)

Hi Simon,

Thanks, that make sense!

I am currently writing script so that it can push live data, of all tags, say every 1 sec to our custom server using REQUESTHTTPX, and almost near to finish it.

However i have one question, when i use datamailbox, the api response for syncdata contains ewon id : 12xxxx and each tag has its own id : 23xxxx and i also get ewon name, but when i look into the documentation of ewon basic programming guide, i do not see anything which get me the ewon id or name as i get in datamailbox api response!! is this something datamailbox add itself? because we are already using these ids (ewon and tag) somewhat, otherwise may be i have to use serial no and need to change some existing functionality to use the new serial no of ewon instead of the ewon id.

Sample partial response from syncdata api call
Code:
{
   "ewon": {
       "id": 123xxx,
       "name": "eWon name xxx",
       "tags": [{
           "id": 433xxx,
           "name": "TAG1",
           "dataType": "Float",
           "description": "",
           "alarmHint": "",
           "value": 34.9,
           "quality": "good",
           "ewonTagId": 1
       }

i don't know if i can get fields with  'xxx' in above code using basic script!! can you please give some direction on this!?

some ref i use for it
https://developer.ewon.biz/content/chang...tags-basic
https://developer.ewon.biz/content/make-...-thingworx

Thanks,
Dhaval
Reply

simon Offline
eWON Support
#11
Dhaval,

Yes, it is something that DatamailBox creates. The eWON is not aware of it.
You could get it through an HTTPS call from the Flexy (REQUESTHTTPX) to "https://data.talk2m.com/getewon?..." or use the serial number instead...
Reply

biztech Offline
Junior Member
#12
(22-02-2017, 03:46 PM)Simon Wrote: Dhaval,

Yes, it is something that DatamailBox creates.  The eWON is not aware of it.
You could get it through an HTTPS call from the Flexy (REQUESTHTTPX) to "https://data.talk2m.com/getewon?..." or use the serial number instead...

Cool , thanks simon!
Reply

biztech Offline
Junior Member
#13
Hi Simon,

One more query!!

We have some 2005CD/4005CD ewons, and we are having hard time converting the script we created for flexy to work on these devices.

Say, for ex. we use requesthttpx to post json data to our sever, with hearder application/json but this is not available in these devices, the one i see is puthttp, which don't allow to set custom header as well as not able to post json data, it sets header to multipart/form-data, like we are submitting html form!

Is there any way i can post json data for this devices?

thanks,
dhaval
Reply

simon Offline
eWON Support
#14
Indeed, the function REQUESTHTTPX is only supported by the Flexy.

However, you can use the following script to create your own HTTP request (with custom header params):

Code:
CallHTTPCustom:
DATATOPOST$ = "TEST=456;"

CLOSE 1
OPEN "tcp:mywebsite.com:8080" FOR BINARY OUTPUT AS 1


Wait1:
B$ = GET 1
IF (B$ = "#CLOSED#") THEN GOTO Wait1

//Header
REQUEST$ = "POST /api/message/form HTTP/1.0" + CHR$(13) + CHR$(10)
REQUEST$ = REQUEST$ + "Host:mywebsite.com" + CHR$(13) + CHR$(10)
REQUEST$ = REQUEST$ + "Authorization:Basic YWRt46YWRtaW4=" + CHR$(13) + CHR$(10)
REQUEST$ = REQUEST$ + "Content-Length:" + STR$ LEN DATATOPOST$ + CHR$(13) + CHR$(10)
REQUEST$ = REQUEST$ + "Content-Type:text/html" + CHR$(13) + CHR$(10) + CHR$(13) + CHR$(10)
//Data
REQUEST$ = REQUEST$ + DATATOPOST$

PUT 1, REQUEST$

TSET 1,2
TIMER1:
IF NOT TGET 1 THEN GOTO TIMER1

A$ = GET 1,1000
PRINT A$

CLOSE 1
Reply

biztech Offline
Junior Member
#15
(05-03-2017, 06:56 PM)Simon Wrote: Indeed, the function REQUESTHTTPX is only supported by the Flexy.

However, you can use the following script to create your own HTTP request (with custom header params):

Code:
CallHTTPCustom:
DATATOPOST$ = "TEST=456;"

CLOSE 1
OPEN "tcp:mywebsite.com:8080" FOR BINARY OUTPUT AS 1


Wait1:
B$ = GET 1
IF (B$ = "#CLOSED#") THEN GOTO Wait1

//Header
REQUEST$ = "POST /api/message/form HTTP/1.0" + CHR$(13) + CHR$(10)
REQUEST$ = REQUEST$ + "Host:mywebsite.com" + CHR$(13) + CHR$(10)
REQUEST$ = REQUEST$ + "Authorization:Basic YWRt46YWRtaW4=" + CHR$(13) + CHR$(10)
REQUEST$ = REQUEST$ + "Content-Length:" + STR$ LEN DATATOPOST$ + CHR$(13) + CHR$(10)
REQUEST$ = REQUEST$ + "Content-Type:text/html" + CHR$(13) + CHR$(10) + CHR$(13) + CHR$(10)
//Data
REQUEST$ = REQUEST$ + DATATOPOST$

PUT 1, REQUEST$

TSET 1,2
TIMER1:
IF NOT TGET 1 THEN GOTO TIMER1

A$ = GET 1,1000
PRINT A$

CLOSE 1

Hi Simon,

Thank you, will try this!

I highly appreciate your help Smile
Reply



Possibly Related Threads…
01-03-2019, 12:39 AM
Last Post: simon



Users browsing this thread:
1 Guest(s)



Theme © Ewon 2019 - Forum software by © MyBB - Cookie policy