diff --git a/pigpio.c b/pigpio.c index 5b127e5..9725ecd 100644 --- a/pigpio.c +++ b/pigpio.c @@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to */ -/* pigpio version 33 */ +/* pigpio version 34 */ /* include ------------------------------------------------------- */ diff --git a/pigpio.h b/pigpio.h index 2ee5684..25fd758 100644 --- a/pigpio.h +++ b/pigpio.h @@ -31,7 +31,7 @@ For more information, please refer to #include #include -#define PIGPIO_VERSION 33 +#define PIGPIO_VERSION 34 /*TEXT @@ -1956,7 +1956,7 @@ D*/ int i2cProcessCall(unsigned handle, unsigned i2cReg, unsigned wVal); /*D This writes 16 bits of data to the specified register of the device -associated with handle and and reads 16 bits of data in return. +associated with handle and reads 16 bits of data in return. . . handle: >=0, as returned by a call to [*i2cOpen*] @@ -3742,7 +3742,7 @@ samples per second. cfgMillis:: 100-10000 -The size of the sample buffer in milliseconds. Gnerally this should be +The size of the sample buffer in milliseconds. Generally this should be left at the default of 120ms. If you expect intense bursts of signals it might be necessary to increase the buffer size. @@ -4063,7 +4063,7 @@ The number of segments in a combined I2C transaction. offset:: The associated data starts this number of microseconds from the start of -tghe waveform. +the waveform. *outBuf:: A buffer used to return data from a function. diff --git a/pigpio.py b/pigpio.py index 3974272..4492671 100644 --- a/pigpio.py +++ b/pigpio.py @@ -263,7 +263,7 @@ import threading import os import atexit -VERSION = "1.18" +VERSION = "1.19" exceptions = True diff --git a/pigs.c b/pigs.c index cc6876c..b97418b 100644 --- a/pigs.c +++ b/pigs.c @@ -33,6 +33,7 @@ This version is for pigpio version 33+ #include #include #include +#include #include #include #include @@ -50,8 +51,13 @@ the commands available from pigpio. char command_buf[8192]; char response_buf[8192]; +int printFlags = 0; + #define SOCKET_OPEN_FAILED -1 +#define PRINT_HEX 1 +#define PRINT_ASCII 2 + void fatal(char *fmt, ...) { char buf[128]; @@ -66,6 +72,30 @@ void fatal(char *fmt, ...) fflush(stderr); } +static int initOpts(int argc, char *argv[]) +{ + int opt, args; + + args = 1; + + while ((opt = getopt(argc, argv, "ax")) != -1) + { + switch (opt) + { + case 'a': + printFlags |= PRINT_ASCII; + args++; + break; + + case 'x': + printFlags |= PRINT_HEX; + args++; + break; + } + } + return args; +} + static int openSocket(void) { int sock, err; @@ -108,7 +138,7 @@ static int openSocket(void) void print_result(int sock, int rv, cmdCmd_t cmd) { - int i, r; + int i, r, ch; uint32_t *p; r = cmd.res; @@ -146,9 +176,20 @@ void print_result(int sock, int rv, cmdCmd_t cmd) if (r < 0) fatal("ERROR: %s", cmdErrStr(r)); if (r > 0) { + if (printFlags == PRINT_ASCII) printf(" "); + for (i=0; i 31) && (ch < 127)) printf("%c", ch); + else printf("\\x%02hhx", ch); + } + else printf(" %hhu", response_buf[i]); } } printf("\n"); @@ -203,7 +244,7 @@ void get_extensions(int sock, int command, int res) int main(int argc , char *argv[]) { int sock, command; - int idx, i, pp, l, len; + int args, idx, i, pp, l, len; cmdCmd_t cmd; uint32_t p[CMD_P_ARR]; cmdCtlParse_t ctl; @@ -212,11 +253,13 @@ int main(int argc , char *argv[]) sock = openSocket(); + args = initOpts(argc, argv); + command_buf[0] = 0; l = 0; pp = 0; - for (i=1; i