GithubHelp home page GithubHelp logo

ole / hexhexhex Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 1.0 18 KB

A parser for the Intel Hexadecimal Object File Format (.hex), written in Swift.

License: MIT License

Swift 100.00%
file-format parser swift intel-hex

hexhexhex's Introduction

HexHexHex

A parser for the Intel Hexadecimal Object File Format (.hex), written in Swift.

Status

Very experimental and untested.

Usage

Add HexHexHex as a Swift Package Manager dependency

dependencies: [
  .package(url: "https://github.com/ole/HexHexHex.git", from: "0.1.0"),
],

Code

Creating a HEXFile value from the text of a .hex file:

import HexHexHex

let hexText = """
  :020000040000FA
  :1000000025001C0C0200080C06006306590AE306D2
  :0C00B000590A000C3000070C2600030069
  :00000001FF
  """
let hexFile = try HEXFile(text: hexText)

The HEXFile value contains an array of Record values that represent the records in the .hex file:

debugPrint(hexFile)
/*
HEXFile (4 records)
  04 extended linear address – 0000
  00 data – address: 0000, data: 25 00 1C 0C 02 00 08 0C 06 00 63 06 59 0A E3 06
  00 data – address: 00B0, data: 59 0A 00 0C 30 00 07 0C 26 00 03 00
  01 end of file
 */

// Get all data records in the file
let dataRecords = hexFile.records.filter { $0.kind == .data }
print(dataRecords)

// Print out the addresses of all data records in the file
for case .data(let address, _) in hexFile.records {
  print(address)
}

Author

Ole Begemann, oleb.net.

License

MIT. See LICENSE.txt.

hexhexhex's People

Contributors

ole avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.