jason-c-daniels - Jcd.SRecord 1.0.29

A .NET Standard 2.0 library to assist with processing motorola s-record (SREC/MOT) format files, often used for firmware.

PM> Install-Package Jcd.SRecord -Version 1.0.29 -Source https://www.myget.org/F/jason-c-daniels/api/v3/index.json

Copy to clipboard

> nuget.exe install Jcd.SRecord -Version 1.0.29 -Source https://www.myget.org/F/jason-c-daniels/api/v3/index.json

Copy to clipboard

> dotnet add package Jcd.SRecord --version 1.0.29 --source https://www.myget.org/F/jason-c-daniels/api/v3/index.json

Copy to clipboard
<PackageReference Include="Jcd.SRecord" Version="1.0.29" />
Copy to clipboard
source https://www.myget.org/F/jason-c-daniels/api/v3/index.json

nuget Jcd.SRecord  ~> 1.0.29
Copy to clipboard

> choco install Jcd.SRecord --version 1.0.29 --source https://www.myget.org/F/jason-c-daniels/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "jason-c-daniels" -SourceLocation "https://www.myget.org/F/jason-c-daniels/api/v2"
Install-Module -Name "Jcd.SRecord" -RequiredVersion "1.0.29" -Repository "jason-c-daniels" 
Copy to clipboard

Jcd.SRecord

This library will load, parse and validate a motorola sRecord file according to the Ubuntu srec manpage and the Wikipedia SREC (file format) article.

Some inspiration was taken from reading the code by Vanya A. Sergeev and Jerry G. Scherer However, you'll note mine is significantly different.

Examples

    // read all of the data, tracking the parse result for each line.
    var document = SRecordDocument.CreateFromFile("FakeFirmware.s37");

    // compute some statistics.
    var parsingStats = document.CalculateParseStatistics();
    var dataStats = document.CalculateDataStatistics();

    // Report on what's in the file.
    Console.WriteLine($"Record type counts:");
    Console.WriteLine($"S0 {dataStats.S0Count}; S1 {dataStats.S1Count}; S2 {dataStats.S2Count}; S3 {dataStats.S3Count}; S4 {dataStats.S4Count}; S5 {dataStats.S5Count}; S6 {dataStats.S6Count}; S7 {dataStats.S7Count}; S8 {dataStats.S8Count}; S9: {dataStats.S9Count}");
    Console.WriteLine();
    Console.WriteLine($"Parsing stats:");
    Console.WriteLine($"Total number of blank lines: {parsingStats.BlankElementCount}");
    Console.WriteLine($"Total number of lines with parsing errors: {parsingStats.ErrorElementCount}");
    Console.WriteLine($"Total number of stand alone comment lines: {parsingStats.StandAloneCommentCount}");
    Console.WriteLine($"Total number of lines with comments: {parsingStats.ElementsWithCommentsCount}");
    Console.WriteLine($"Total number of lines with s-record entries: {parsingStats.ElementsWithSRecordDataCount}");
    Console.WriteLine($"Total number of lines with comments and s-record entries: {parsingStats.SRecordDataWithCommentCount}");
    Console.WriteLine($"Total line count: {parsingStats.TotalElementsCount}");
    /* The above gives the following output:
    Record type counts:
    S0 1; S1 3; S2 0; S3 0; S4 0; S5 1; S6 0; S7 0; S8 0; S9: 1

    Parsing stats:
    Total number of blank lines: 0
    Total number of lines with parsing errors: 0
    Total number of stand alone comment lines: 3
    Total number of lines with comments: 3
    Total number of lines with s-record entries: 6
    Total number of lines with comments and s-record entries: 0
    Total line count: 9
    */

    // now access the data and upload the firmware to a device.
    foreach (var record in document.SRecords)
    {
        // get a byte array if it's S1, S2, S3 and send firmware to the device.
        if (record.Type.Key == "S1" || record.Type.Key == "S2" || record.Type.Key == "S3")
            UploadToFirmware(record.Address, record.Type.AddressLengthInBytes, record.Data.ToArray());
        // set the execution address if S7, S8, or S9
        else if (record.Type.Key == "S7" || record.Type.Key == "S8" || record.Type.Key == "S9")
            SetExecutionAddress(record.Address,record.Type.AddressLengthInBytes);
    }

GitHub Build status CodeFactor Grade

MyGet Nuget

API Docs

updated nuget dependencies and updated language version in use.

  • .NETStandard 2.0
    • Jcd.Netstandard20.Shim (>= 1.0.1)
    • Jcd.Validations (>= 1.2.0)
    • Microsoft.Bcl.AsyncInterfaces (>= 8.0.0)
    • System.Memory (>= 4.5.5)
  • .NETStandard 2.0: 2.0.0.0

Owners

Jason C. Daniels

Authors

Jason C Daniels

Project URL

https://github.com/jason-c-daniels/Jcd.SRecord

License

MIT

Tags

srec s-record srecord mot s37 s28 s19 firmware c# csharp c-sharp

Info

8 total downloads
2 downloads for version 1.0.29
Download (57.33 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
1.0.29 57.33 KB Wed, 13 Mar 2024 23:50:36 GMT 2
1.0.15 35.03 KB Sat, 30 Jul 2022 00:01:14 GMT 2
1.0.14 35.03 KB Sat, 30 Jul 2022 00:00:02 GMT 2
1.0.12 35.03 KB Fri, 29 Jul 2022 22:21:04 GMT 2