The node-picmd is a client library for picmd.
The node-picmd is a client library for picmd, a command handler framework with serial communication for Raspberry PI.
It abstracts the communication specification of picmd and makes it easy to use.
The sample code for sending the "0x01" command and receiving the response is as follows.
const { PiCmd } = require('@ushiboy/picmd');
(async function() {
const pic = PiCmd.connect('/dev/ttyUSB0');
const r = await pic.request(0x01);
console.log(r.value.toString('utf-8'));
}());
The picmd client class.
Create an instance of PiCmd by passing the serial port path.
- parameters
- port
- The serial port path.
- type: string
- port
- return
- The instance of PiCmd.
- type: PiCmd
Wait until there is a PING response.
- optional parameters
- retry
- Number of times to repeat the PING command.
- type: number
- default:
20
- retry
Send a ping command.
- optional parameters
- timeout
- Timeout waiting for a ping command response.
- type: number
- default:
2000
ms
- timeout
Send a command and return a response.
- parameters
- command
- The command to send.
- type: number
- command
- optional parameters
- data
- The data of the command to be sent.
- type: Buffer
- timeout
- Timeout waiting for a command response.
- type: number
- default:
60000
ms
- data
- return
- The result of the execution of the command.
- type: CommandResponse
The result of the execution of the command.
- properties
- status
- The status of the command execution result.
- type: number
- size
- The response data size of command execution result.
- type: number
- value
- The response data of command execution result.
- type: Buffer
- parity
- The parity value for checking
- type: number
- status
Fix example code.
Initial release.
MIT