2635A
Users Manual

C-2

number of channels for the scan. The following C code converts a LOG_BIN? responsestring into a byte array:
/*
-* decode(): Decode LOG_BIN? response string into raw byte stream
**
** Decoding is done on multiples of four input bytes:
**
** 543210 543210 543210 543210 (bit number in ASCII bytes)
** +--------+--------+--------+--------+
** | src[0] | src[1] | src[2] | src[3] | ASCII string input
** +--------+--------+--------+--------+
** 765432 107654 321076 543210 (bit number in raw bytes)
** / / /
** / / /
** | / /
** | / /
** | | /
** | | /
** | | |
** 76543210 76543210 76543210 (bit number in raw bytes)
** +--------+--------+--------+
** | dst[0] | dst[1] | dst[2] | Raw data output
** +--------+--------+--------+
**
** Inputs:
** dst Destination for binary data (must have enough space
** allocated; the maximum needed is 6 timestamp bytes + 3
** bytes for temp units, measurement rate, and digital I/O
** + 4 bytes/float * 22 floating point values = 97 bytes).
**
** src Source ASCII string (null terminated)
**
** Outputs:
** dst Set to binary data, based on ASCII string
**
** Returns:
** Number of bytes placed in destination buffer
*/
int
decode(dst, src)
unsigned char *dst;
char *src;
{
/* src to dst xlate */
static struct nibtab_s {
int lindex;
int lmask;
int lshift;
int rindex;
int rmask;
int rshift;
} nibtab[3] = {
/* left right */