{"id":15412257,"url":"https://github.com/robthree/cfnreader","last_synced_at":"2025-03-01T19:30:51.827Z","repository":{"id":255205563,"uuid":"848888294","full_name":"RobThree/CFNReader","owner":"RobThree","description":"Provides a simple way to read FNIRSI's CFN files (*.cfn) produced by the FNIRSI UsbMeter tool","archived":false,"fork":false,"pushed_at":"2024-08-28T16:02:20.000Z","size":171,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-01T18:19:19.825Z","etag":null,"topics":["cfn","csv","data","fnirsi","usb","usb-tester"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/CFNReader","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RobThree.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["RobThree"],"custom":["https://paypal.me/robiii"]}},"created_at":"2024-08-28T15:33:08.000Z","updated_at":"2024-08-28T16:02:24.000Z","dependencies_parsed_at":"2024-08-28T16:11:32.770Z","dependency_job_id":"c586625b-50c8-47b2-a68f-e6d4c708fa48","html_url":"https://github.com/RobThree/CFNReader","commit_stats":null,"previous_names":["robthree/cfnreader"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FCFNReader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FCFNReader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FCFNReader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FCFNReader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobThree","download_url":"https://codeload.github.com/RobThree/CFNReader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241414518,"owners_count":19959228,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cfn","csv","data","fnirsi","usb","usb-tester"],"created_at":"2024-10-01T16:51:59.179Z","updated_at":"2025-03-01T19:30:51.550Z","avatar_url":"https://github.com/RobThree.png","language":"C#","funding_links":["https://github.com/sponsors/RobThree","https://paypal.me/robiii"],"categories":[],"sub_categories":[],"readme":"# ![Logo](https://raw.githubusercontent.com/RobThree/CFNReader/master/icon.png) CFNReader\n\n# Introduction\n\nProvides a simple way to read FNIRSI's CFN files (`*.cfn`) produced by the FNIRSI UsbMeter tool ([here](https://www.fnirsi.com/pages/download-firmware)). With this library you can also convert `*.cfn` files to CSV files easily. Available as [NuGet package](https://www.nuget.org/packages/CFNReader).\n\n# QuickStart\n\n```c#\nusing var myfile = File.OpenRead(\"myfile.cfn\");\nvar cfnreader = new CFNStreamReader(myfile);\n\n// Read general file information\nvar fileinfo = await cfnreader.ReadFileInfoAsync();\n\n// Read and print data points\nawait foreach (var datapoint in cfnreader.ReadDatapointsAsync(fileinfo))\n{\n    Console.WriteLine(\n        string.Join(\"\\t\", [datapoint.Time.ToString(\"G\"), datapoint.Values[Channel.VBusVoltage], datapoint.Values[Channel.VBusCurrent]])\n    );\n}\n```\n\nOutput:\n\n```cmd\n0:00:00:00,0000000      0.0000V 0.0126A\n0:00:00:00,0100000      0.0100V 0.0126A\n0:00:00:00,0200000      0.0200V 0.0126A\n0:00:00:00,0300000      0.0300V 0.0126A\n0:00:00:00,0400000      0.0400V 0.0126A\n...\n```\n\nThe `CFNStreamReader` class provides two methods to read the file: `ReadFileInfoAsync` and `ReadDatapointsAsync`. The first one reads the file header and returns a `FileInfo` object. The second one reads the data points and returns an `IAsyncEnumerable\u003cDataPoint\u003e`. Both methods are asynchronous and support cancellation using a `CancellationToken`.\n\n# Convert to CSV\n\nA simple way to convert the data to a CSV is provided by the `CFNCSVConverter`:\n\n```c#\nusing var myfile = File.OpenRead(\"myfile.cfn\");\nusing var csvfile = File.Create(\"export.csv\");\n\nvar csvconverter = new CFNCSVConverter(\n    channels: [Channel.AccumulatedCapacity, Channel.VBusVoltage],\n    predicate: dp =\u003e dp.Values[Channel.VBusVoltage] \u003e 0.5,\n    includeUnit: true,\n    limitDataPoints: 1000\n);\n\nawait csvconverter.ConvertToCSVAsync(testfile, csvfile);\n```\n\nThe `CFNCSVConverter` class constructor accepts the following (optional) parameters:\n\n- `channels`: An array of `Channel` values to include in the CSV. The order of the channels in the array will be the order of the columns in the CSV.\n- `predicate`: A function that receives a `Datapoint` and returns a boolean. If the function returns `true`, the `Datapoint` will be included in the CSV.\n- `formatProvider`: An `IFormatProvider` to use when formatting the values.\n- `separator`: The separator to use between the values (default `;`).\n- `encoding`: The encoding to use when writing the CSV file (default `UTF8`).\n- `timeFormat`: The format to use when formatting the time values (default `G`).\n- `valueFormat`: The format to use when formatting the values (default `N4`).\n- `includeHeader`: Wether to include the header row in the CSV.\n- `includeTime`: Wether to include the time column (always first column).\n- `includeUnit`: Wether to include the unit of the value(s) like `A` (amps) or `V` (volts) for example.\n- `limitDataPoints`: The maximum number of data points to include in the CSV (default `int.MaxValue`)\n\n# Acknowledgements\n\nThis library is based on [didim99](https://github.com/didim99)'s work in [usbmeter-utils](https://github.com/didim99/usbmeter-utils/tree/master).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobthree%2Fcfnreader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobthree%2Fcfnreader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobthree%2Fcfnreader/lists"}