30 static const CnvParams _hex = CNV_DEFAULT_HEX;
33 const char cmd_bps_help[] =
"BPS - Configure and Read";
50 static uint16_t bpshexShort(
const char * input)
58 if (
cnvParseU(input, &out, params) != 4) {
64 static uint16_t bpsdecShort(
const char * input)
69 if (
cnvParseU(input, &out, params) <= 0) {
78 bool cmd_bps_exec(
int argc,
const char *args[])
87 if (argc < 1 || ((argc == 1) && (strcmp(args[0],
"help") == 0))) {
88 puts(
"usage: bps sensors -- read sensors");
89 puts(
" bps alarm en load|save [opt] -- enable alarm (load or save) - opt = hex value to be saved");
90 puts(
" bps alarm th load|save [th_375 th_12v]-- Threshold alarm (load or save) - th.. = decimal values to be saved");
91 puts(
" bps alarm clear -- clear alarm");
92 puts(
" bps toggle back|12v-- toggle breakers");
93 puts(
" bps ping -- get fw version");
98 else if(argc == 1 && strcmp(args[0],
"sensors") == 0){
102 printf(
"I(backbone) = %d\n", sens.mon_i);
103 printf(
"I(12V) = %d\n", sens.mon1_i12);
104 printf(
"V(375V) = %d\n", sens.mon2_v375);
105 printf(
"I(375V) = %d\n", sens.mon3_i375);
106 printf(
"V(5V) = %d\n", sens.mon4_v375);
108 printf(
"I(backbone) = = 0x%x\n", sens.mon_i);
109 printf(
"I(12V) = 0x%x\n", sens.mon1_i12);
110 printf(
"V(375V) = 0x%x\n", sens.mon2_v375);
111 printf(
"I(375V) = 0x%x\n", sens.mon3_i375);
112 printf(
"V(5V) = 0x%x\n", sens.mon4_v375);
114 printf(
"al = 0x%x\n", sens.alarm);
115 printf(
"break = 0x%x\n", sens.breaker);
119 else if(argc >= 2 && strcmp(args[0],
"alarm") == 0){
120 if(argc >= 3 && strcmp(args[1],
"th")== 0){
121 if(argc == 5 && strcmp(args[2],
"save")== 0){
123 wth.thr_mon_375i0 = bpsdecShort(args[3]);
124 wth.thr_mon_12v = bpsdecShort(args[4]);
127 printf(
"TH 375V I0 = %d\n",rth.thr_mon_375i0 );
128 printf(
"TH 12V I0 = %d\n",rth.thr_mon_12v);
131 else if(argc == 3 && strcmp(args[2],
"load")== 0){
134 printf(
"TH 375V I0 = %d\n",rth.thr_mon_375i0 );
135 printf(
"TH 12V I0 = %d\n",rth.thr_mon_12v);
137 printf(
"TH 375V I0 = 0x%x\n",rth.thr_mon_375i0 );
138 printf(
"TH 12V I0 = 0x%x\n",rth.thr_mon_12v);
143 else if(argc >= 3 && strcmp(args[1],
"en")== 0){
144 if(argc == 4 && strcmp(args[2],
"save")== 0){
145 wsal = bpshexShort(args[3]);
146 printf(
"%s - ret 0x%x\n",
bpsAlarmEnSave(wsal, &rsal)?
"Done":
"Error",rsal);
148 else if(argc == 3 && strcmp(args[2],
"load")== 0){
149 printf(
"%s - ret 0x%x\n",
bpsAlarmEnLoad(&rsal)?
"Done":
"Error",rsal);
153 else if(argc == 2 && strcmp(args[1],
"clear")== 0){
158 else if(argc == 2 && strcmp(args[0],
"toggle") == 0){
159 if(strcmp(args[1],
"back") == 0){
162 else if(strcmp(args[1],
"12v") == 0) {
163 printf(
"%s - re 0x%x\n",bpsRelayToggle12V(&rsal)?
"Done":
"Error",rsal);
167 else if(argc == 1 && strcmp(args[0],
"ping") == 0){
168 printf(
"%s - ret 0x%x\n",
bpsPingDevice(&fw)?
"Done":
"Error",fw);
bool bpsRelayToggleBackBone(uint16_t *breakers)
Toggle relay status.
int cnvParseU(const char *input, uint32_t *output, CnvParams params)
Parse an unsigned integer.
bool bpsAlarmClearStat(uint16_t *alarms)
Clear Status Alarm.
bool bpsAlarmThLoad(BspTh *th)
load already saved alarm threshold (in mA)
Simple task scheduler for tasks.
#define CNV_BASE_HEX
Base of hex numbers.
bool bpsPingDevice(uint16_t *fw)
Ping Device.
#define CNV_DEFAULT
Default conversion/formatting parameters (base 10).
bool bpsAlarmThSave(BspTh *newth, BspTh *th)
save alarm threshold (in mA)
Manages the global system error.
This structure provides information about formatting and parsing.
bool bpsReadSensor(BpsRdSensAnsw *stat)
return sensor values
This module is responsible for distributing error codes.
uint8_t base
Base of the number to format or parse.
bool bpsAlarmEnSave(uint16_t newal, uint16_t *alarms)
save alarm enable
This module implements parsing and formating of strings and integers.
bool bpsAlarmEnLoad(uint16_t *alarms)
Load already saved alarm enable.