<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Tracker Simulator]]></title><description><![CDATA[<p dir="auto">Can anybody help me with an example of a tracker simulator that sends parameters from a CSV file to a server via UDP.</p>
<p dir="auto">The message is HEX. The idea is that the script can read parameters from a csv file, use current date/time and create the string following the next table format. Then send the message and go to the next CSV file line. There must be a delay after every message sent.</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Keyword</th>
<th>Default Value</th>
<th>Bytes</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>OptionsByte</td>
<td>83</td>
<td>1</td>
<td>Indicates the type of data in the message</td>
</tr>
<tr>
<td>MobileIDLength</td>
<td>08</td>
<td>1</td>
<td>Length of MobileID in bytes</td>
</tr>
<tr>
<td>MobileID</td>
<td>"From CSV file"</td>
<td>8</td>
<td>ID of the device that originated the message</td>
</tr>
<tr>
<td>MobileIDTypeLen</td>
<td>01</td>
<td>1</td>
<td>Length of the MobileID type</td>
</tr>
<tr>
<td>MobileIDType</td>
<td>02</td>
<td>1</td>
<td>Type of identification (IMEI, ESN, etc.)</td>
</tr>
<tr>
<td>Service Type</td>
<td>01</td>
<td>1</td>
<td>Type of service for the message</td>
</tr>
<tr>
<td>Message Type</td>
<td>02</td>
<td>1</td>
<td>Type of message (event, report, etc.)</td>
</tr>
<tr>
<td>Sequence#</td>
<td>0000</td>
<td>2</td>
<td>Sequence number of the message</td>
</tr>
<tr>
<td>Update Time</td>
<td>"Current Time"</td>
<td>4</td>
<td>Time of message update</td>
</tr>
<tr>
<td>Time of Fix</td>
<td>"Current Time"</td>
<td>4</td>
<td>Time of the last GPS fix</td>
</tr>
<tr>
<td>Latitude</td>
<td>"From CSV file"</td>
<td>4</td>
<td>Latitude in decimal degrees</td>
</tr>
<tr>
<td>Longitude</td>
<td>"From CSV file"</td>
<td>4</td>
<td>Longitude in decimal degrees</td>
</tr>
<tr>
<td>Altitude</td>
<td>"From CSV file"</td>
<td>4</td>
<td>Altitude in centimeters</td>
</tr>
<tr>
<td>Speed</td>
<td>"From CSV file"</td>
<td>4</td>
<td>Speed in centimeters per second</td>
</tr>
<tr>
<td>Heading</td>
<td>"From CSV file"</td>
<td>2</td>
<td>Heading in degrees from true north</td>
</tr>
<tr>
<td>Satellites</td>
<td>10</td>
<td>1</td>
<td>Number of satellites used</td>
</tr>
<tr>
<td>Fix Status</td>
<td>02</td>
<td>1</td>
<td>GPS fix status</td>
</tr>
<tr>
<td>Carrier</td>
<td>0004</td>
<td>2</td>
<td>Network carrier identifier</td>
</tr>
<tr>
<td>RSSI</td>
<td>FFBF</td>
<td>2</td>
<td>Received signal strength indicator</td>
</tr>
<tr>
<td>Comm State</td>
<td>0F</td>
<td>1</td>
<td>Communication modem state</td>
</tr>
<tr>
<td>HDOP</td>
<td>00</td>
<td>1</td>
<td>Horizontal dilution of precision</td>
</tr>
<tr>
<td>Inputs</td>
<td>"From CSV file"</td>
<td>1</td>
<td>Status of digital inputs</td>
</tr>
<tr>
<td>Unit Status</td>
<td>A1</td>
<td>1</td>
<td>Status of key modules within the unit</td>
</tr>
<tr>
<td>Event Index</td>
<td>99</td>
<td>1</td>
<td>Index of the event that generated the report</td>
</tr>
<tr>
<td>Event Code</td>
<td>03</td>
<td>1</td>
<td>Event code reported</td>
</tr>
<tr>
<td>Accums</td>
<td>06</td>
<td>1</td>
<td>Number of accumulators</td>
</tr>
<tr>
<td>Spare</td>
<td>00</td>
<td>1</td>
<td>Reserved space, not used</td>
</tr>
<tr>
<td>Accum 0</td>
<td>00000000</td>
<td>4</td>
<td>First accumulator</td>
</tr>
<tr>
<td>Accum 1</td>
<td>00000000</td>
<td>4</td>
<td>Second accumulator</td>
</tr>
<tr>
<td>Accum 2</td>
<td>10600000</td>
<td>4</td>
<td>Third accumulator</td>
</tr>
<tr>
<td>Accum 3</td>
<td>001A35DF</td>
<td>4</td>
<td>Fourth accumulator</td>
</tr>
<tr>
<td>Accum 4</td>
<td>02C80269</td>
<td>4</td>
<td>Fifth accumulator</td>
</tr>
<tr>
<td>Accum 5</td>
<td>62347EF0</td>
<td>4</td>
<td>Sixth accumulator</td>
</tr>
</tbody>
</table>
<p dir="auto">An example of the output could be this one:</p>
<p dir="auto">8308860796050307380F01020102000066BADC8166BADC8105F30E41CE7B98490000000000000000007410020004FFBF0F001Ea199030600000000000000106000000000001A35DF02C8026962347EF0</p>
<p dir="auto">Thanks.</p>
]]></description><link>http://64.23.185.212/forum/topic/314/tracker-simulator</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Jul 2026 05:12:03 GMT</lastBuildDate><atom:link href="http://64.23.185.212/forum/topic/314.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 15 Aug 2024 19:12:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Tracker Simulator on Fri, 13 Sep 2024 17:32:45 GMT]]></title><description><![CDATA[<p dir="auto">I thought I responded to your answer Vladimir. Thank you for taking the time to create the script. I can tell you that it works perfectly and has saved me a lot of time in testing tasks. By the way, the process is very efficient and precise.</p>
]]></description><link>http://64.23.185.212/forum/post/694</link><guid isPermaLink="true">http://64.23.185.212/forum/post/694</guid><dc:creator><![CDATA[Luis Ramírez]]></dc:creator><pubDate>Fri, 13 Sep 2024 17:32:45 GMT</pubDate></item><item><title><![CDATA[Reply to Tracker Simulator on Sat, 24 Aug 2024 10:46:27 GMT]]></title><description><![CDATA[<p dir="auto">This script only generates packet contents and passes the raw data to the underlying session for transmission -- so it will work with any transport. If you need to send those packets over UDP, open the "UDP Socket" plugin, configure remote IP:Port accordingly, then run the script:</p>
<p dir="auto"><img src="/forum/assets/uploads/files/1724496279144-8b2ce837-f29d-47ec-ae0e-78923db521f0-image.png" alt="8b2ce837-f29d-47ec-ae0e-78923db521f0-image.png" class=" img-responsive img-markdown" width="1023" height="876" /></p>
]]></description><link>http://64.23.185.212/forum/post/692</link><guid isPermaLink="true">http://64.23.185.212/forum/post/692</guid><dc:creator><![CDATA[Vladimir]]></dc:creator><pubDate>Sat, 24 Aug 2024 10:46:27 GMT</pubDate></item><item><title><![CDATA[Reply to Tracker Simulator on Sat, 24 Aug 2024 10:33:33 GMT]]></title><description><![CDATA[<p dir="auto">Here's a script that will open a CSV file, parse it line by line, then prepare and transmit binary packets for each line:</p>
<pre><code>import "io_base.jncx"
import "io_MappedFile.jnc"

enum: uint64_t {
	// epoch difference (in seconds) between Unix time (1 Jan 1970 00:00) and Windows time (1 Jan. 1601 00:00)
	UnixTimeEpochDiff = 11644473600,

	// delay between packets (in milliseconds)
	InterPacketDelay  = 500, 
}

// the structure of the packet

pragma(Alignment, 1)

struct Packet {
	uint8_t m_optionsByte             = 0x83;
	uint8_t m_mobileIdLength          = 0x08;
	bigendian uint64_t m_mobileId;
	uint8_t m_mobileIdTypeLen         = 0x01;
	uint8_t m_mobileIdType            = 0x02;
	uint8_t m_serviceType             = 0x01;
	uint8_t m_messageType             = 0x02;
	bigendian uint16_t m_sequenceIdx;
	bigendian uint32_t m_updateTime;
	bigendian uint32_t m_timeOfFix;
	bigendian uint32_t m_latitude;
	bigendian uint32_t m_longitude;
	bigendian uint32_t m_altitude;
	bigendian uint32_t m_speed;
	bigendian uint16_t m_heading;
	uint8_t m_satellites              = 0x0B;
	uint8_t m_fixStatus               = 0x02;
	bigendian uint16_t m_carrier      = 0x0004;
	bigendian uint16_t m_rssi         = 0xFFBF;
	uint8_t m_commState               = 0x0F;
	uint8_t m_hdop                    = 0x09;
	uint8_t m_inputs;
	uint8_t m_unitStatus              = 0x01;
	uint8_t m_eventIndex              = 0x04;
	uint8_t m_eventCode               = 0xA8;
	uint8_t m_accums                  = 0x06;
	uint8_t m_spare                   = 0x00;
	bigendian uint32_t m_accum0       = 0x00000000;
	bigendian uint32_t m_accum1       = 0x00000000;
	bigendian uint32_t m_accum2       = 0x10600000;
	bigendian uint32_t m_accum3       = 0x001A35DF;
	bigendian uint32_t m_accum4       = 0x02C80269;
	bigendian uint32_t m_accum5       = 0x62347EF0;
	char m_lf                         = '\n';
}

char const* findEol(
	char const* p,
	char const* eof
) {
	char const* eol = memchr(p, '\n', eof - p);
	return eol ? eol + 1 : eof;
}

void main() {
	connect();

	string_t fileName = io.getHomeDir() + "/history.csv"; // adjust accordingly
	io.MappedFile file;
	file.open(fileName, io.FileOpenFlags.ReadOnly);

	size_t size = file.m_size;
	char const* p = file.view(0, size);
	char const* eof = p + size;
	size_t index = 0;

	Packet packet; // all const fields are initialized; we'll adjust variable fields below

	p = findEol(p, eof); // skip the first line
	while (p &lt; eof) { // process the rest line by line	
		char const* eol = findEol(p, eof);
		string_t line(p, eol - p);
		p = eol;
		
		if (line !~ r"\s*([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*)")
			continue; // skip all CSV lines that do not match the pattern

		// Jancy uses Windows timestamps (in 100-nsec intervals, i.e. sec / 10^7)
		uint_t unixTime = sys.getTimestamp() / 10000000 - UnixTimeEpochDiff;		

		// adjust all the variable fields in the packet
		packet.m_mobileId = strtoul($1,, 16);
		packet.m_sequenceIdx = index++;
		packet.m_updateTime = unixTime;
		packet.m_timeOfFix = unixTime;
		packet.m_latitude = (uint_t)(atof($3) * 10000000);
		packet.m_longitude = (uint_t)(atof($4) * 10000000);
		packet.m_altitude = (uint_t)(atof($5) * 100);
		packet.m_speed = (uint_t)(atof($6) * 100);
		packet.m_heading = strtoul($7);
		packet.m_inputs = strtoul($8);

		// transmit, wait and move on to the next line
		transmit(&amp;packet, sizeof(packet));
		sys.sleep(InterPacketDelay); 
	}
}

</code></pre>
<p dir="auto">Unlike the original PHP sample I received from you, I didn't generate a HEX string first -- in Jancy, it's much cleaner (and more efficient, of course) to generate binary data right away. First, we declare the <code>Packet</code> struct according to your specification and initialize all constant fields; then, we walk over the file line by line and adjust fields that depend on the CSV data.</p>
<p dir="auto">Feel free to ask any questions regarding the script.</p>
]]></description><link>http://64.23.185.212/forum/post/691</link><guid isPermaLink="true">http://64.23.185.212/forum/post/691</guid><dc:creator><![CDATA[Vladimir]]></dc:creator><pubDate>Sat, 24 Aug 2024 10:33:33 GMT</pubDate></item></channel></rss>