FMStoIP

In this example enable ITxPT on Netmodule NG800 and receive specific CAN Data of the router via ITxPT implementation. As a client, we use a pc with linux-debian 10.

Requirements:

1. Step

SERVICES → ITxPT → Configuration → ITxPT Administratio enable. Choose your LAN Interface, your client is connected to. In our case this is LAN1.

2. Step

Go to FMStoIP Tab, and configure as followed:

3. Step

To get any FMS data from the database on the webserver, once we need to enable all possible PGN IDs on the fmstoip service. Therefore we will use a simple http request sdk script. Please configure a sdk job with eventbased trigger set to “sdk-startup”. Then add the following script into the script section:

fms-add-all-pgn.are
/*DESC: This script add all avaliable PGNs fmsv4.json to the FMStoIP database.
* Copyright (C) 2013-2022) NetModule AG, Switzerland
*/
 
url = 'http://192.168.1.1:8085/fmstoip/addpgn';
usr = "";
pwd = "";
path = "";
pp = "";
resp = "";
//define headers
header = "content-type: text/xml";
 
// ALL POSSIBLE PGN VALUES [HEX]     
pgn= mkarray("F000", "F001", "F002", "F003", "F004", "F005", "F009", "FD09", "FD7D", "FDA4", "FDA5", "FDD1", "FE4E", "FE56", "FE6B", "FE6C", "FE70", "FEAE", "FEBF", "FEC0", "FEC1", "FED5", "FEE5", "FEE9", "FEEA", "FEEC", "FEEE", "FEEF", "FEF1", "FEF2", "FEF5", "FEF6", "FEF8", "FEF8", "FEFB", "FEFC");
 
for(i=0; i<length(pgn); i++) {
     // POST request
     f = fopen("content", "w");
     fwrite(f, '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n');
     fwrite(f, sprintf("<PGNReq>%s</PGNReq>", pgn[i]));
     fclose(f);
     req = nb_transfer_post(usr ,pwd ,url ,path ,pp ,resp ,header);
     printf("added PGN:%s\n\n", pgn[i]);
}

Don't forget to edit your router IP in the url! It is set to default 192.168.1.1

4. Step

* How to set up the discovery tool avahi under an LXC container

Almost done, now we need to discover the services offered by netmodule ITxPT service. As discovery tool, we use avahi-discover. Once, started, we can click on a service to get detail information.

Now we have the multicast address for the fmstoip service discovered, we can join the multicast group and recvice the udp messages.

Note: If you are connected to other networks too, make sure to add a route 239.0.0.0/8 via 192.168.1.1 for the multicast address.

5. Step

Please clone https://github.com/troglobit/mtools and build the mtools:

USER
timm@debian:~/git$ git clone https://github.com/troglobit/mtools Cloning into 'mtools'… remote: Enumerating objects: 103, done. remote: Total 103 (delta 0), reused 0 (delta 0), pack-reused 103 Receiving objects: 100% (103/103), 48.67 KiB | 2.32 MiB/s, done. Resolving deltas: 100% (53/53), done. timm@debian:~/git$ cd mtools/ timm@debian:~/git/mtools$ make

CC      msend.o
LINK    msend
CC      mreceive.o
LINK    mreceive

timm@debian:~/git/mtools$

6. Step

Now we can start mrecevie, with multiacast IP and port: ./mreceive -g 239.255.42.21 -p 15015

output.txt
timm@debian:~/git/mtools$ ./mreceive -g 239.255.42.21 -p 15015
Now receiving from multicast group: 239.255.42.21
Receive msg 1 from 192.168.1.1:60429: <?xml version="1.0"?><FMStoIPDelivery version="1.1a"><FMStoIP FMSVersion="0000"><Frame Status="OK"><PGN>F001</PGN><Data>FF0000FFFFFFFFDD</Data><RelativeTime>1671119801118</RelativeTime><SPN id="1243"><Name>ABS Fully Operational</Name><Value>Not available</Value></SPN></Frame><Frame Status="OK"><PGN>F001</PGN><Data>FF0000FFFFFFFFDD</Data><RelativeTime>1671119801118</RelativeTime><SPN id="1243"><Name>ABS Fully Operational</Name><Value>Not available</Value></SPN></Frame></FMStoIP></FMStoIPDelivery>
Receive msg 2 from 192.168.1.1:60429: <?xml version="1.0"?><FMStoIPDelivery version="1.1a"><FMStoIP FMSVersion="0000"><Frame Status="OK"><PGN>F002</PGN><Data>FF0000FFFFFFFFDD</Data><RelativeTime>1671119811052</RelativeTime><SPN id="522"><Name>Percent Clutch Slip</Name><Unit>%</Unit><Value>102.0</Value></SPN></Frame><Frame Status="OK"><PGN>F002</PGN><Data>FF0000FFFFFFFFDD</Data><RelativeTime>1671119811051</RelativeTime><SPN id="522"><Name>Percent Clutch Slip</Name><Unit>%</Unit><Value>102.0</Value></SPN></Frame></FMStoIP></FMStoIPDelivery>
result.xml
<?xml version="1.0"?>
<FMStoIPDelivery version="1.1a">
	<FMStoIP FMSVersion="0000">
		<Frame Status="OK">
			<PGN>F001</PGN>
			<Data>FF0000FFFFFFFFDD</Data>
			<RelativeTime>1671119801118</RelativeTime>
			<SPN id="1243">
				<Name>ABS Fully Operational</Name>
				<Value>Not available</Value>
			</SPN>
		</Frame>
		<Frame Status="OK">
			<PGN>F001</PGN>
			<Data>FF0000FFFFFFFFDD</Data>
			<RelativeTime>1671119801118</RelativeTime>
			<SPN id="1243">
				<Name>ABS Fully Operational</Name>
				<Value>Not available</Value>
			</SPN>
		</Frame>
	</FMStoIP>
</FMStoIPDelivery>
<?xml version="1.0"?>
<FMStoIPDelivery version="1.1a">
	<FMStoIP FMSVersion="0000">
		<Frame Status="OK">
			<PGN>F002</PGN>
			<Data>FF0000FFFFFFFFDD</Data>
			<RelativeTime>1671119811052</RelativeTime>
			<SPN id="522">
				<Name>Percent Clutch Slip</Name>
				<Unit>%</Unit>
				<Value>102.0</Value>
			</SPN>
		</Frame>
		<Frame Status="OK">
			<PGN>F002</PGN>
			<Data>FF0000FFFFFFFFDD</Data>
			<RelativeTime>1671119811051</RelativeTime>
			<SPN id="522">
				<Name>Percent Clutch Slip</Name>
				<Unit>%</Unit>
				<Value>102.0</Value>
			</SPN>
		</Frame>
	</FMStoIP>
</FMStoIPDelivery>