Skip to content

AN1388 UART bootloader programmer implemented in Node.js

Notifications You must be signed in to change notification settings

bbales/AN1388-Node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AN1388-Node

Implementation of Microchip's AN1388 PIC32 bootloader in Node.js using UART. Adapted from Camil Staps' python implementation.

It is a good idea to add the current user to the dialout group, allowing access to reading and writing /dev/ devices using this command: usermod -a -G dialout $USER. Most methods accept byte array arguments.

API

Programmer ⇐ EventEmitter

Instantiable bootloader programmer class. Provides access to serial port UART programmer

Kind: global class
Extends: EventEmitter

new Programmer(baudRate)

Create a programmer instance

Param Type Default Description
baudRate number 115200 A standard UART baudrate, defaults to 115200

programmer.connected ⇒ boolean

Alias for checking connection status

Kind: instance property of Programmer
Returns: boolean - - connection status

programmer.debugEnable()

Enable debugging

Kind: instance method of Programmer

programmer.onceConnected() ⇒ Promise

This resolves when the device is properly connected - a good starting point for a program

Kind: instance method of Programmer
Returns: Promise - - a promise that resolves when the programmer is connected

programmer.crc16(data) ⇒ array

Cyclic Redundency Check (CRC) 16-bit data - Verified

Kind: instance method of Programmer
Returns: array - - an array of 2 bytes that represent the CRC

Param Type Description
data array an array of bytes to calculate the CRC for

programmer.escape(data) ⇒ array

Escape Control Characters

Kind: instance method of Programmer
Returns: array - - escaped byte array

Param Type Description
data array array of bytes to escape

programmer.unescape(data) ⇒ array

Unescape Control Characters

Kind: instance method of Programmer
Returns: array - - unescaped byte array

Param Type Description
data array array of bytes to unescape

programmer.send(command) ⇒ number

Send A Command - synchronous

Kind: instance method of Programmer
Returns: number - - length of command sent

Param Type Description
command array byte array representing command

programmer.upload(filename) ⇒ Promise

Upload/Flash a Hex File

Kind: instance method of Programmer
Returns: Promise - - promise that resolves on upload success, rejects on error
Emits: uploadProgress

Param Type Default Description
filename string "test.hex" location of Intel formatted hexfile to upload

programmer.version() ⇒ Promise

Fetch bootloader version

Kind: instance method of Programmer
Returns: Promise - - promise that resolves when the version is returned

programmer.run()

Run program

Kind: instance method of Programmer

"uploadProgress"

Upload Progress events

Kind: event emitted by Programmer
Properties

Name Type Description
total number Total bytes to be sent
sent number Bytes sent
percent number Percentage of bytes sent

About

AN1388 UART bootloader programmer implemented in Node.js

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published