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.
Instantiable bootloader programmer class. Provides access to serial port UART programmer
Kind: global class
Extends: EventEmitter
- Programmer ⇐
EventEmitter
- new Programmer(baudRate)
- .connected ⇒
boolean
- .debugEnable()
- .onceConnected() ⇒
Promise
- .crc16(data) ⇒
array
- .escape(data) ⇒
array
- .unescape(data) ⇒
array
- .send(command) ⇒
number
- .upload(filename) ⇒
Promise
- .version() ⇒
Promise
- .run()
- "uploadProgress"
Create a programmer instance
Param | Type | Default | Description |
---|---|---|---|
baudRate | number |
115200 |
A standard UART baudrate, defaults to 115200 |
Alias for checking connection status
Kind: instance property of Programmer
Returns: boolean
- - connection status
Enable debugging
Kind: instance method of Programmer
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
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 |
Escape Control Characters
Kind: instance method of Programmer
Returns: array
- - escaped byte array
Param | Type | Description |
---|---|---|
data | array |
array of bytes to escape |
Unescape Control Characters
Kind: instance method of Programmer
Returns: array
- - unescaped byte array
Param | Type | Description |
---|---|---|
data | array |
array of bytes to unescape |
Send A Command - synchronous
Kind: instance method of Programmer
Returns: number
- - length of command sent
Param | Type | Description |
---|---|---|
command | array |
byte array representing command |
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 |
Fetch bootloader version
Kind: instance method of Programmer
Returns: Promise
- - promise that resolves when the version is returned
Run program
Kind: instance method of Programmer
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 |