Hi all,
I'm new win
Java and I have small problem to get bytes via stdout, and from them create JSON.
Sensor simulator file is .EXE (
https://drive.google.com/open?id=1WZj6vmAfzFysCRUYgymqqueh-wt-1cue )
Problem is next:
The simulator can be spawned with a --name argument. If no name is given, a random name will be generated.
I can have a few .EXE files and over stdout and mapping bytes I need to write JSON in log file.
JSON should have this format:
Sensor data format
The sensor data is a binary format. Each reading will be packaged with the length of the packet, a
timestamp, a name of the sensor, and the available sensor readings. Strings are in UTF-8. Numerical
values are in network byte order.
Offset | Field name | Type | Size | Description |
---|
0 | plength | unsigned integer | 4 bytes | The length of package, including this field |
4 | timestamp | unsigned integer | 8 bytes | Unix timestamp, in milliseconds |
12 | nlen | unsigned integer | 1 byte | The length of the name |
13 | name | string | nlen bytes | The length of the name |
13 + nlen | temperature | unsigned integer | 3 bytes | In hundredths of K |
16 + nlen (13 +nlen) | humidity | unsigned integer | 2 bytes | Relative humidity in ‰ |
Note: Both temperature and humidity are optional. This means that the offset for humidity can
also be 13 + nlen.
I did something like this, but I don't think that I'm on the good way:
I need this ASAP, so please help me to solve, also to understand
Thank you!