Skip to content
Snippets Groups Projects
Commit 34c7ad3f authored by simimeie's avatar simimeie
Browse files

new escape sequences for variable width temperature and linefeeds (untested)

parent 3d07cb4a
No related branches found
No related tags found
No related merge requests found
/* $Id: hostsoftware.c,v 1.8 2010/03/23 07:52:25 simimeie Exp $
/* $Id: hostsoftware.c,v 1.9 2010/07/10 18:04:51 simimeie Exp $
* This is the control software for the ds1820-to-usb device that runs
* on the USB host to which the device is connected.
* You will need libusb and its development headers to compile this.
......@@ -394,12 +394,22 @@ static void printtooutbuf(char * outbuf, int oblen, struct daemondata * dd) {
for (i = 5; i >= 0; i--) {
outbuf += sprintf(outbuf, "%02x", dd->serial[i]);
}
} else if (*pos == 'T') { /* Temperature */
} else if ((*pos == 'T') || (*pos == 't')) { /* Temperature */
if ((dd->lastseen + 60) < time(NULL)) { /* Stale data / no data yet */
outbuf += sprintf(outbuf, "%s", "N/A");
} else {
outbuf += sprintf(outbuf, "%6.2lf", dd->lasttemp);
if (*pos == 'T') { /* fixed width */
outbuf += sprintf(outbuf, "%6.2lf", dd->lasttemp);
} else { /* variable width. */
outbuf += sprintf(outbuf, "%.2lf", dd->lasttemp);
}
}
} else if (*pos == 'r') { /* carriage return */
*outbuf = '\r';
outbuf++;
} else if (*pos == 'n') { /* linefeed / Newline */
*outbuf = '\n';
outbuf++;
} else if (*pos == 'L') { /* Last seen */
outbuf += sprintf(outbuf, "%u", (unsigned int)dd->lastseen);
} else if (*pos == 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment