command.h
Go to the documentation of this file.
1 /*
2 This is free and unencumbered software released into the public domain.
3 
4 Anyone is free to copy, modify, publish, use, compile, sell, or
5 distribute this software, either in source code form or as a compiled
6 binary, for any purpose, commercial or non-commercial, and by any
7 means.
8 
9 In jurisdictions that recognize copyright laws, the author or authors
10 of this software dedicate any and all copyright interest in the
11 software to the public domain. We make this dedication for the benefit
12 of the public at large and to the detriment of our heirs and
13 successors. We intend this dedication to be an overt act of
14 relinquishment in perpetuity of all present and future rights to this
15 software under copyright law.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 OTHER DEALINGS IN THE SOFTWARE.
24 
25 For more information, please refer to <http://unlicense.org/>
26 */
27 
28 /*
29 This version is for pigpio version 57+
30 */
31 
32 #ifndef COMMAND_H
33 #define COMMAND_H
34 
35 #include <stdio.h>
36 #include <string.h>
37 
38 #include "pigpio.h"
39 
40 #define CMD_MAX_PARAM 512
41 #define CMD_MAX_EXTENSION (1<<16)
42 
43 #define CMD_UNKNOWN_CMD -1
44 #define CMD_BAD_PARAMETER -2
45 #define CMD_EXT_TOO_SMALL -3
46 
47 #define CMD_P_ARR 10
48 #define CMD_V_ARR 10
49 
50 #define CMD_NUMERIC 1
51 #define CMD_VAR 2
52 #define CMD_PAR 3
53 
54 typedef struct
55 {
56  uint32_t cmd;
57  uint32_t p1;
58  uint32_t p2;
59  union
60  {
61  uint32_t p3;
62  uint32_t ext_len;
63  uint32_t res;
64  };
65 } cmdCmd_t;
66 
67 typedef struct
68 {
69  int eaten;
70  int8_t opt[4];
72 
73 typedef struct
74 {
75  int cmd; /* command number */
76  char *name; /* command name */
77  int vt; /* command verification type */
78  int rv; /* command return value type */
79 } cmdInfo_t;
80 
81 typedef struct
82 {
83  uint32_t tag;
84  int step;
85 } cmdTagStep_t;
86 
87 typedef struct
88 {
89  uint32_t p[5];
90  int8_t opt[4];
91 } cmdInstr_t;
92 
93 typedef struct
94 {
95  /*
96  +-----------+---------+---------+----------------+
97  | PARAMS... | VARS... | CMDS... | STRING AREA... |
98  +-----------+---------+---------+----------------+
99  */
100  int *par;
101  int *var;
103  int instrs;
104  char *str_area;
107 } cmdScript_t;
108 
109 extern cmdInfo_t cmdInfo[];
110 
111 extern char *cmdUsage;
112 
113 int cmdParse(char *buf, uint32_t *p, unsigned ext_len, char *ext, cmdCtlParse_t *ctl);
114 
115 int cmdParseScript(char *script, cmdScript_t *s, int diags);
116 
117 char *cmdErrStr(int error);
118 
119 char *cmdStr(void);
120 
121 #endif
122 
cmdScript_t::par
int * par
Definition: command.h:100
error
void error(const char *msg)
Definition: embedded_linux_comms.c:39
cmdStr
char * cmdStr(void)
Definition: command.c:624
cmdTagStep_t
Definition: command.h:81
cmdUsage
char * cmdUsage
Definition: command.c:264
cmdInfo_t::vt
int vt
Definition: command.h:77
cmdCtlParse_t
Definition: command.h:67
cmdInfo_t::rv
int rv
Definition: command.h:78
cmdCmd_t
Definition: command.h:54
cmdErrStr
char * cmdErrStr(int error)
Definition: command.c:1248
cmdCmd_t::p3
uint32_t p3
Definition: command.h:61
cmdCmd_t::res
uint32_t res
Definition: command.h:63
cmdInfo
cmdInfo_t cmdInfo[]
Definition: command.c:41
cmdTagStep_t::step
int step
Definition: command.h:84
cmdCmd_t::ext_len
uint32_t ext_len
Definition: command.h:62
cmdInstr_t
Definition: command.h:87
cmdInfo_t
Definition: command.h:73
cmdCtlParse_t::eaten
int eaten
Definition: command.h:69
cmdCmd_t::p2
uint32_t p2
Definition: command.h:58
cmdParse
int cmdParse(char *buf, uint32_t *p, unsigned ext_len, char *ext, cmdCtlParse_t *ctl)
Definition: command.c:629
DHT22.s
s
Definition: DHT22.py:257
pigpio.h
cmdInfo_t::cmd
int cmd
Definition: command.h:75
cmdTagStep_t::tag
uint32_t tag
Definition: command.h:83
cmdScript_t::instr
cmdInstr_t * instr
Definition: command.h:102
cmdScript_t::str_area_len
int str_area_len
Definition: command.h:105
cmdParseScript
int cmdParseScript(char *script, cmdScript_t *s, int diags)
Definition: command.c:1259
cmdScript_t::str_area_pos
int str_area_pos
Definition: command.h:106
cmdCmd_t::cmd
uint32_t cmd
Definition: command.h:56
cmdScript_t::str_area
char * str_area
Definition: command.h:104
cmdScript_t::var
int * var
Definition: command.h:101
cmdCmd_t::p1
uint32_t p1
Definition: command.h:57
cmdScript_t
Definition: command.h:93
cmdInfo_t::name
char * name
Definition: command.h:76
cmdScript_t::instrs
int instrs
Definition: command.h:103


cob_hand_bridge
Author(s): Mathias Lüdtke
autogenerated on Fri Aug 2 2024 09:40:56