From 0b20d3e37430439a2dd6d448ef1ee39f7b4dd17d Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Sat, 24 Apr 2010 14:56:31 +0000 Subject: [PATCH] multi power ids --- powersensordaemon/powersensordaemon.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/powersensordaemon/powersensordaemon.c b/powersensordaemon/powersensordaemon.c index 6b1a371..ac96ef0 100644 --- a/powersensordaemon/powersensordaemon.c +++ b/powersensordaemon/powersensordaemon.c @@ -100,24 +100,26 @@ int send_command(int tty_fd, cmd_t* cmd) if(!cmd) return -1; - char c; + if(!cmd->param) + return 0; + + unsigned int j,cmd_param_len = strnlen(cmd->param,60); + + char c[cmd_param_len]; switch(cmd->cmd) { case POWER_ON: { - if(!cmd->param) - return 0; - c = toupper(cmd->param[0]); + for (j=0; j< cmd_param_len; j++) + c[j] = toupper(cmd->param[j]); break; } case POWER_OFF: { - if(!cmd->param) - return 0; - c = tolower(cmd->param[0]); + for (j=0; j< cmd_param_len; j++) + c[j] = tolower(cmd->param[j]); break; } case SAMPLE: { - if(!cmd->param) - return 0; - c = cmd->param[0]; + for (j=0; j< cmd_param_len; j++) + c[j] = cmd->param[j]; break; } default: return 0; @@ -125,7 +127,7 @@ int send_command(int tty_fd, cmd_t* cmd) int ret; do { - ret = write(tty_fd, &c, 1); + ret = write(tty_fd, c, cmd_param_len); } while(!ret || (ret == -1 && errno == EINTR)); if(ret > 0) { -- 1.7.10.4