How to find time stamp and decimal value reading from data stream in Java

ExpertHacker

So if we pretend that we have the following data being streamed into Java from a microcontroller using Serial Port:

0x21 0x32 0xCC 0x00 0x3A 0x98 0x02 0x12 0x03 0x21 0x33 0x01 0xC2

I initially believed that the first byte was the Magic Number and the second byte was the Key. So wouldn't that make the numbers 0xCC 0x00 0x3A 0x98 0x02 0x12 0x03 0x21 0x33 0x01 0xC2 the value that we're reading from the microcontroller which we just combined all of the numbers in order to get the following reading in decimal value: 204058... and on?

And for the time stamp don't we just convert the second byte which is 0x32 to decimal which is 50 unites of time?

Andreas

Quoting comment:

on the documentation it mentioned that the payload was a key-value pair and 0x32 was for "timestamp, 4-byte integer, milliseconds since reset" and 0x33 "potentiometer reading, 2-byte integer A/D counts" so does that mean the next time I hit 0x32 which is the second number and since its a 4-byte integer we concatonate 0xCC and 0x00 0x3A and 0x98?

Quoting example data from question:

0x21 0x32 0xCC 0x00 0x3A 0x98 0x02 0x12 0x03 0x21 0x33 0x01 0xC2

So, key/value pairs, where the key is a single byte, and each key has values of differing length.

0x32 was for "timestamp, 4-byte integer, milliseconds since reset"

0x21 0x32 0xCC 0x00 0x3A 0x98 0x02 0x12 0x03 0x21 0x33 0x01 0xC2
     ^^^^ ^^^^^^^^^^^^^^^^^^^
     key    4-byte integer

Those 4 bytes can be big-endian or little-endian, but big-endian is more common for devices, so:

0xCC003A98 = 3422567064 ms = 39 days 14 hrs 42 mins 47.064 secs

0x33 "potentiometer reading, 2-byte integer A/D counts"

0x21 0x32 0xCC 0x00 0x3A 0x98 0x02 0x12 0x03 0x21 0x33 0x01 0xC2
                                                  ^^^^ ^^^^^^^^^
                                                  key  2-byte integer

0x01C2 = 450

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to log Serial data with time stamp?

分類Dev

Java Stream: How to find id from json?

分類Dev

Unix Time stamp creation in C from custom data fields

分類Dev

Getting epoch time from gmt time stamp

分類Dev

remove specific characters from time stamp

分類Dev

pulling a time stamp from a txt file

分類Dev

How to stamp prompt at command execute time?

分類Dev

How is the time stamp number in /etc/shadow calculated?

分類Dev

Find cumulative sum of a list while reading data from csv file

分類Dev

how to return a number with 2 decimal places all the time from a function

分類Dev

Get Time stamp using Java GMT+5:30

分類Dev

How to push the data from dynamodb through stream

分類Dev

How to work with a Javascript +Date() numeric time stamp in Python?

分類Dev

time series data reading performance

分類Dev

how to find time difference from row names?

分類Dev

Python StreamIO reading and writing from the same stream

分類Dev

Multiple listeners reading from the same stream in NodeJS

分類Dev

Reading a list of Files as a Java 8 Stream

分類Dev

Find number of decimal places in decimal value regardless of culture

分類Dev

Golang find a value from a map of nested json data from MongoDB

分類Dev

how to set the eighth bit to zero (reading data from smarcard)

分類Dev

How to find longest prefix from array list using given string value in Java?

分類Dev

How to find a value from a specific element by name?

分類Dev

How to find the Second value from a table.?

分類Dev

Java stream to find occurrences in a list

分類Dev

How to remove seasonality from time series data?

分類Dev

How to find overlapping time slices of serveral key-value elements

分類Dev

Can the time stamp of a Retweet be accessed?

分類Dev

How to find data from nested array?

Related 関連記事

  1. 1

    How to log Serial data with time stamp?

  2. 2

    Java Stream: How to find id from json?

  3. 3

    Unix Time stamp creation in C from custom data fields

  4. 4

    Getting epoch time from gmt time stamp

  5. 5

    remove specific characters from time stamp

  6. 6

    pulling a time stamp from a txt file

  7. 7

    How to stamp prompt at command execute time?

  8. 8

    How is the time stamp number in /etc/shadow calculated?

  9. 9

    Find cumulative sum of a list while reading data from csv file

  10. 10

    how to return a number with 2 decimal places all the time from a function

  11. 11

    Get Time stamp using Java GMT+5:30

  12. 12

    How to push the data from dynamodb through stream

  13. 13

    How to work with a Javascript +Date() numeric time stamp in Python?

  14. 14

    time series data reading performance

  15. 15

    how to find time difference from row names?

  16. 16

    Python StreamIO reading and writing from the same stream

  17. 17

    Multiple listeners reading from the same stream in NodeJS

  18. 18

    Reading a list of Files as a Java 8 Stream

  19. 19

    Find number of decimal places in decimal value regardless of culture

  20. 20

    Golang find a value from a map of nested json data from MongoDB

  21. 21

    how to set the eighth bit to zero (reading data from smarcard)

  22. 22

    How to find longest prefix from array list using given string value in Java?

  23. 23

    How to find a value from a specific element by name?

  24. 24

    How to find the Second value from a table.?

  25. 25

    Java stream to find occurrences in a list

  26. 26

    How to remove seasonality from time series data?

  27. 27

    How to find overlapping time slices of serveral key-value elements

  28. 28

    Can the time stamp of a Retweet be accessed?

  29. 29

    How to find data from nested array?

ホットタグ

アーカイブ