Make get-i2c-health.js output uptime and baud rate.
This commit is contained in:
@@ -37,7 +37,32 @@ function slaveI2cErrorBufferToString(buffer, slaveId) {
|
||||
return str;
|
||||
}
|
||||
|
||||
function convertMs(milliseconds) {
|
||||
let days, hours, minutes, seconds;
|
||||
seconds = Math.floor(milliseconds / 1000);
|
||||
minutes = Math.floor(seconds / 60);
|
||||
seconds = seconds % 60;
|
||||
hours = Math.floor(minutes / 60);
|
||||
minutes = minutes % 60;
|
||||
days = Math.floor(hours / 24);
|
||||
hours = hours % 24;
|
||||
return {days, hours, minutes, seconds};
|
||||
}
|
||||
|
||||
const device = uhk.getUhkDevice();
|
||||
|
||||
device.write(uhk.getTransferData(new Buffer(uhk.pushUint32([uhk.usbCommands.getDeviceProperty, uhk.devicePropertyIds.uptime]))));
|
||||
let response = device.readSync();
|
||||
let uptimeMs = uhk.getUint32(response, 1);
|
||||
let uptime = convertMs(uptimeMs);
|
||||
console.log(`uptime: ${uptime.days}d ${String(uptime.hours).padStart(2, '0')}:${String(uptime.minutes).padStart(2, '0')}:${String(uptime.seconds).padStart(2, '0')}`)
|
||||
|
||||
device.write(uhk.getTransferData(new Buffer(uhk.pushUint32([uhk.usbCommands.getDeviceProperty, uhk.devicePropertyIds.i2cBaudRate]))));
|
||||
response = device.readSync();
|
||||
let requestedBaudRate = uhk.getUint32(response, 2);
|
||||
let actualBaudRate = uhk.getUint32(response, 6);
|
||||
console.log(`requestedBaudRate:${requestedBaudRate} | actualBaudRate:${actualBaudRate} | I2C0_F:0b${response[1].toString(2).padStart(8, '0')}`)
|
||||
|
||||
for (let slaveId=0; slaveId<6; slaveId++) {
|
||||
device.write(uhk.getTransferData(new Buffer([uhk.usbCommands.getSlaveI2cErrors, slaveId])));
|
||||
let response = Buffer.from(device.readSync());
|
||||
|
||||
Reference in New Issue
Block a user