Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mbpoll.c; Add CSV writing option #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hhedeshian
Copy link

Add support to write polled data into a CSV file. This implementation honors the format setting. The CSV file will have a header line generated containing the column names. Columns include the UTC timestamp in RFC3339 format as well as the device IDs and register numbers. For int16 values, the output differes from the console output: the columns are duplicated and both the signed and unsigned values are recorded in the CSV. This makes it easier to process the CSV on popular spreadsheet applications without having to do a bunch of nasty conversions.

Add support to write polled data into a CSV file. This implementation
honors the format setting. The CSV file will have a header line
generated containing the column names. Columns include the UTC timestamp
in RFC3339 format as well as the device IDs and register numbers. For
int16 values, the output differes from the console output: the columns
are duplicated and both the signed and unsigned values are recorded in
the CSV. This makes it easier to process the CSV on popular spreadsheet
applications without having to do a bunch of nasty conversions.
@hhedeshian
Copy link
Author

Example usage:
./mbpoll -m tcp -a 1 -r 131 -c 2 -t 3 -O test.csv 10.0.0.15

Example output:
cat test.csv

"Time (UTC)","ID","Register[131][u]","Register[131][s]","Register[132][u]","Register[132][s]"
2023-10-01T16:31:19Z,1,51200,-14336,1734,1734
2023-10-01T16:31:21Z,1,51200,-14336,1731,1731
2023-10-01T16:31:22Z,1,51200,-14336,1734,1734
2023-10-01T16:31:23Z,1,51200,-14336,1731,1731
2023-10-01T16:31:24Z,1,51200,-14336,1734,1734
2023-10-01T16:31:26Z,1,51200,-14336,1734,1734
2023-10-01T16:31:27Z,1,51200,-14336,1731,1731
2023-10-01T16:31:28Z,1,51200,-14336,1734,1734
2023-10-01T16:31:29Z,1,51200,-14336,1734,1734

@hhedeshian hhedeshian changed the title Update mbpoll.c Update mbpoll.c; Add CSV writing option Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant