Compare commits
6 Commits
Release-2-
...
stream_2_5
Author | SHA1 | Date | |
---|---|---|---|
6e6c79f5ea | |||
8da0014091 | |||
60d292b3ea | |||
5ce9b737cf | |||
7bcb494044 | |||
13758eb08e |
4
makefile
4
makefile
@ -34,7 +34,6 @@ SOURCES += $(FORMATS:%=src/%Converter.cc)
|
|||||||
SOURCES += $(BUSSES:%=src/%Interface.cc)
|
SOURCES += $(BUSSES:%=src/%Interface.cc)
|
||||||
SOURCES += $(wildcard src/Stream*.cc)
|
SOURCES += $(wildcard src/Stream*.cc)
|
||||||
SOURCES += src/StreamVersion.c
|
SOURCES += src/StreamVersion.c
|
||||||
SOURCES_3.14 += src/devcalcoutStream.c
|
|
||||||
|
|
||||||
HEADERS += StreamFormat.h
|
HEADERS += StreamFormat.h
|
||||||
HEADERS += StreamFormatConverter.h
|
HEADERS += StreamFormatConverter.h
|
||||||
@ -44,6 +43,9 @@ HEADERS += StreamError.h
|
|||||||
ifeq (${EPICS_BASETYPE},3.13)
|
ifeq (${EPICS_BASETYPE},3.13)
|
||||||
USR_INCLUDES += -include $(INSTALL_INCLUDE)/compat3_13.h
|
USR_INCLUDES += -include $(INSTALL_INCLUDE)/compat3_13.h
|
||||||
endif
|
endif
|
||||||
|
ifeq (${EPICS_BASETYPE},3.14)
|
||||||
|
RECORDTYPES += calcout
|
||||||
|
endif
|
||||||
|
|
||||||
StreamCore.o: streamReferences
|
StreamCore.o: streamReferences
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ static ulong crc_0x04C11DB7(const uchar* data, ulong len, ulong crc)
|
|||||||
{
|
{
|
||||||
// x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 +
|
// x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 +
|
||||||
// x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + x^0 (0x04C11DB7)
|
// x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + x^0 (0x04C11DB7)
|
||||||
const static ulong table[] = {
|
const static unsigned int table[] = {
|
||||||
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9,
|
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9,
|
||||||
0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
|
0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
|
||||||
0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
|
0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
|
||||||
@ -340,7 +340,7 @@ static ulong crc_0x04C11DB7_r(const uchar* data, ulong len, ulong crc)
|
|||||||
// x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 +
|
// x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 +
|
||||||
// x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + x^0 (0x04C11DB7)
|
// x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + x^0 (0x04C11DB7)
|
||||||
// reflected
|
// reflected
|
||||||
const static ulong table[] = {
|
const static unsigned int table[] = {
|
||||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
|
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
|
||||||
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
||||||
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
||||||
@ -545,9 +545,9 @@ printPseudo(const StreamFormat& format, StreamBuffer& output)
|
|||||||
debug("ChecksumConverter %s: output to check: \"%s\"\n",
|
debug("ChecksumConverter %s: output to check: \"%s\"\n",
|
||||||
checksumMap[fnum].name, output.expand(start,length)());
|
checksumMap[fnum].name, output.expand(start,length)());
|
||||||
|
|
||||||
sum = checksumMap[fnum].xorout ^ checksumMap[fnum].func(
|
sum = (checksumMap[fnum].xorout ^ checksumMap[fnum].func(
|
||||||
reinterpret_cast<uchar*>(output(start)), length,
|
reinterpret_cast<uchar*>(output(start)), length,
|
||||||
checksumMap[fnum].init) & mask[checksumMap[fnum].bytes];
|
checksumMap[fnum].init)) & mask[checksumMap[fnum].bytes];
|
||||||
|
|
||||||
debug("ChecksumConverter %s: output checksum is 0x%lX\n",
|
debug("ChecksumConverter %s: output checksum is 0x%lX\n",
|
||||||
checksumMap[fnum].name, sum);
|
checksumMap[fnum].name, sum);
|
||||||
@ -555,6 +555,17 @@ printPseudo(const StreamFormat& format, StreamBuffer& output)
|
|||||||
int i;
|
int i;
|
||||||
unsigned outchar;
|
unsigned outchar;
|
||||||
|
|
||||||
|
if (format.flags & sign_flag) // decimal
|
||||||
|
{
|
||||||
|
// get number of decimal digits from number of bytes: ceil(xbytes*2.5)
|
||||||
|
i = (checksumMap[fnum].bytes+1)*25/10-2;
|
||||||
|
output.print("%0*ld", i, sum);
|
||||||
|
debug("ChecksumConverter %s: decimal appending %0*ld\n",
|
||||||
|
checksumMap[fnum].name, i, sum);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (format.flags & alt_flag) // lsb first (little endian)
|
if (format.flags & alt_flag) // lsb first (little endian)
|
||||||
{
|
{
|
||||||
for (i = 0; i < checksumMap[fnum].bytes; i++)
|
for (i = 0; i < checksumMap[fnum].bytes; i++)
|
||||||
@ -563,7 +574,7 @@ printPseudo(const StreamFormat& format, StreamBuffer& output)
|
|||||||
debug("ChecksumConverter %s: little endian appending 0x%X\n",
|
debug("ChecksumConverter %s: little endian appending 0x%X\n",
|
||||||
checksumMap[fnum].name, outchar);
|
checksumMap[fnum].name, outchar);
|
||||||
if (format.flags & zero_flag) // ASCII
|
if (format.flags & zero_flag) // ASCII
|
||||||
output.printf("%02X", outchar);
|
output.print("%02X", outchar);
|
||||||
else // binary
|
else // binary
|
||||||
output.append(outchar);
|
output.append(outchar);
|
||||||
sum >>= 8;
|
sum >>= 8;
|
||||||
@ -578,7 +589,7 @@ printPseudo(const StreamFormat& format, StreamBuffer& output)
|
|||||||
debug("ChecksumConverter %s: big endian appending 0x%X\n",
|
debug("ChecksumConverter %s: big endian appending 0x%X\n",
|
||||||
checksumMap[fnum].name, outchar);
|
checksumMap[fnum].name, outchar);
|
||||||
if (format.flags & zero_flag) // ASCII
|
if (format.flags & zero_flag) // ASCII
|
||||||
output.printf("%02X", outchar);
|
output.print("%02X", outchar);
|
||||||
else // binary
|
else // binary
|
||||||
output.append(outchar);
|
output.append(outchar);
|
||||||
sum <<= 8;
|
sum <<= 8;
|
||||||
@ -606,9 +617,9 @@ scanPseudo(const StreamFormat& format, StreamBuffer& input, long& cursor)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sum = checksumMap[fnum].xorout ^ checksumMap[fnum].func(
|
sum = (checksumMap[fnum].xorout ^ checksumMap[fnum].func(
|
||||||
reinterpret_cast<uchar*>(input(start)), length,
|
reinterpret_cast<uchar*>(input(start)), length,
|
||||||
checksumMap[fnum].init) & mask[checksumMap[fnum].bytes];
|
checksumMap[fnum].init)) & mask[checksumMap[fnum].bytes];
|
||||||
|
|
||||||
debug("ChecksumConverter %s: input checksum is 0x%0*lX\n",
|
debug("ChecksumConverter %s: input checksum is 0x%0*lX\n",
|
||||||
checksumMap[fnum].name, 2*checksumMap[fnum].bytes, sum);
|
checksumMap[fnum].name, 2*checksumMap[fnum].bytes, sum);
|
||||||
@ -616,6 +627,24 @@ scanPseudo(const StreamFormat& format, StreamBuffer& input, long& cursor)
|
|||||||
int i,j;
|
int i,j;
|
||||||
unsigned inchar;
|
unsigned inchar;
|
||||||
|
|
||||||
|
if (format.flags & sign_flag) // decimal
|
||||||
|
{
|
||||||
|
ulong sumin = 0;
|
||||||
|
// get number of decimal digits from number of bytes: ceil(xbytes*2.5)
|
||||||
|
j = (checksumMap[fnum].bytes+1)*25/10-2;
|
||||||
|
for (i = 0; i < j; i++)
|
||||||
|
{
|
||||||
|
inchar = input[cursor+i];
|
||||||
|
if (isdigit(inchar)) sumin = sumin*10+inchar-'0';
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
if (sumin==sum) return i;
|
||||||
|
error("Input %0*lu does not match checksum %0*lu\n",
|
||||||
|
i, sumin, j, sum);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (format.flags & alt_flag) // lsb first (little endian)
|
if (format.flags & alt_flag) // lsb first (little endian)
|
||||||
{
|
{
|
||||||
for (i = 0; i < checksumMap[fnum].bytes; i++)
|
for (i = 0; i < checksumMap[fnum].bytes; i++)
|
||||||
|
@ -75,7 +75,7 @@ printDouble(const StreamFormat& fmt, StreamBuffer& output, double value)
|
|||||||
int prec = fmt.prec;
|
int prec = fmt.prec;
|
||||||
|
|
||||||
if (prec < 1) prec = 6;
|
if (prec < 1) prec = 6;
|
||||||
buf.printf("%.*e", prec-1, fabs(value)/pow(10.0, prec-1));
|
buf.print("%.*e", prec-1, fabs(value)/pow(10.0, prec-1));
|
||||||
buf.remove(1,1);
|
buf.remove(1,1);
|
||||||
buf.remove(buf.find('e'),1);
|
buf.remove(buf.find('e'),1);
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
|||||||
}
|
}
|
||||||
if (*source == esc) {
|
if (*source == esc) {
|
||||||
source++;
|
source++;
|
||||||
pattern.printf("\\x%02x", *source++ & 0xFF);
|
pattern.print("\\x%02x", *source++ & 0xFF);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pattern.append(*source++);
|
pattern.append(*source++);
|
||||||
|
@ -248,7 +248,7 @@ replace(long remstart, long remlen, const void* ins, long inslen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
StreamBuffer& StreamBuffer::
|
StreamBuffer& StreamBuffer::
|
||||||
printf(const char* fmt, ...)
|
print(const char* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
int printed;
|
int printed;
|
||||||
@ -296,7 +296,7 @@ StreamBuffer StreamBuffer::expand(long start, long length) const
|
|||||||
c = buffer[i];
|
c = buffer[i];
|
||||||
if ((c & 0x7f) < 0x20 || (c & 0x7f) == 0x7f)
|
if ((c & 0x7f) < 0x20 || (c & 0x7f) == 0x7f)
|
||||||
{
|
{
|
||||||
result.printf("<%02x>", c & 0xff);
|
result.print("<%02x>", c & 0xff);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -312,17 +312,17 @@ dump() const
|
|||||||
StreamBuffer result(256+cap*5);
|
StreamBuffer result(256+cap*5);
|
||||||
result.append("\033[0m");
|
result.append("\033[0m");
|
||||||
long i;
|
long i;
|
||||||
result.printf("%ld,%ld,%ld:\033[37m", offs, len, cap);
|
result.print("%ld,%ld,%ld:\033[37m", offs, len, cap);
|
||||||
for (i = 0; i < cap; i++)
|
for (i = 0; i < cap; i++)
|
||||||
{
|
{
|
||||||
if (i == offs) result.append("\033[34m[\033[0m");
|
if (i == offs) result.append("\033[34m[\033[0m");
|
||||||
if ((buffer[i] & 0x7f) < 0x20 || (buffer[i] & 0x7f) == 0x7f)
|
if ((buffer[i] & 0x7f) < 0x20 || (buffer[i] & 0x7f) == 0x7f)
|
||||||
{
|
{
|
||||||
if (i < offs || i >= offs+len)
|
if (i < offs || i >= offs+len)
|
||||||
result.printf(
|
result.print(
|
||||||
"<%02x>", buffer[i] & 0xff);
|
"<%02x>", buffer[i] & 0xff);
|
||||||
else
|
else
|
||||||
result.printf(
|
result.print(
|
||||||
"\033[34m<%02x>\033[37m", buffer[i] & 0xff);
|
"\033[34m<%02x>\033[37m", buffer[i] & 0xff);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#define StreamBuffer_h
|
#define StreamBuffer_h
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifndef __GNUC__
|
#ifndef __GNUC__
|
||||||
#define __attribute__(x)
|
#define __attribute__(x)
|
||||||
@ -189,7 +188,7 @@ public:
|
|||||||
StreamBuffer& insert(long pos, char c)
|
StreamBuffer& insert(long pos, char c)
|
||||||
{return replace(pos, 0, &c, 1);}
|
{return replace(pos, 0, &c, 1);}
|
||||||
|
|
||||||
StreamBuffer& printf(const char* fmt, ...)
|
StreamBuffer& print(const char* fmt, ...)
|
||||||
__attribute__ ((format(printf,2,3)));
|
__attribute__ ((format(printf,2,3)));
|
||||||
|
|
||||||
// find: get index of data in buffer or -1
|
// find: get index of data in buffer or -1
|
||||||
|
@ -57,12 +57,12 @@ static char* printCommands(StreamBuffer& buffer, const char* c)
|
|||||||
break;
|
break;
|
||||||
case wait_cmd:
|
case wait_cmd:
|
||||||
timeout = extract<unsigned long>(c);
|
timeout = extract<unsigned long>(c);
|
||||||
buffer.printf(" wait %ld;\n # ms", timeout);
|
buffer.print(" wait %ld;\n # ms", timeout);
|
||||||
break;
|
break;
|
||||||
case event_cmd:
|
case event_cmd:
|
||||||
eventnumber = extract<unsigned long>(c);
|
eventnumber = extract<unsigned long>(c);
|
||||||
timeout = extract<unsigned long>(c);
|
timeout = extract<unsigned long>(c);
|
||||||
buffer.printf(" event(%ld) %ld; # ms\n", eventnumber, timeout);
|
buffer.print(" event(%ld) %ld; # ms\n", eventnumber, timeout);
|
||||||
break;
|
break;
|
||||||
case exec_cmd:
|
case exec_cmd:
|
||||||
buffer.append(" exec \"");
|
buffer.append(" exec \"");
|
||||||
@ -71,7 +71,7 @@ static char* printCommands(StreamBuffer& buffer, const char* c)
|
|||||||
break;
|
break;
|
||||||
case connect_cmd:
|
case connect_cmd:
|
||||||
timeout = extract<unsigned long>(c);
|
timeout = extract<unsigned long>(c);
|
||||||
buffer.printf(" connect %ld; # ms\n", timeout);
|
buffer.print(" connect %ld; # ms\n", timeout);
|
||||||
break;
|
break;
|
||||||
case disconnect_cmd:
|
case disconnect_cmd:
|
||||||
buffer.append(" disconnect;\n");
|
buffer.append(" disconnect;\n");
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "StreamError.h"
|
#include "StreamError.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
int streamDebug = 0;
|
int streamDebug = 0;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
#ifndef StreamError_h
|
#ifndef StreamError_h
|
||||||
#define StreamError_h
|
#define StreamError_h
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifndef __GNUC__
|
#ifndef __GNUC__
|
||||||
#define __attribute__(x)
|
#define __attribute__(x)
|
||||||
|
@ -316,7 +316,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
|||||||
bool StdLongConverter::
|
bool StdLongConverter::
|
||||||
printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||||
{
|
{
|
||||||
output.printf(fmt.info, value);
|
output.print(fmt.info, value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,7 +395,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
|||||||
bool StdDoubleConverter::
|
bool StdDoubleConverter::
|
||||||
printDouble(const StreamFormat& fmt, StreamBuffer& output, double value)
|
printDouble(const StreamFormat& fmt, StreamBuffer& output, double value)
|
||||||
{
|
{
|
||||||
output.printf(fmt.info, value);
|
output.print(fmt.info, value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,7 +451,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
|||||||
bool StdStringConverter::
|
bool StdStringConverter::
|
||||||
printString(const StreamFormat& fmt, StreamBuffer& output, const char* value)
|
printString(const StreamFormat& fmt, StreamBuffer& output, const char* value)
|
||||||
{
|
{
|
||||||
output.printf(fmt.info, value);
|
output.print(fmt.info, value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,7 +549,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
|||||||
bool StdCharsConverter::
|
bool StdCharsConverter::
|
||||||
printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||||
{
|
{
|
||||||
output.printf(fmt.info, value);
|
output.print(fmt.info, value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -634,7 +634,7 @@ printString(StreamBuffer& buffer, const char* s)
|
|||||||
switch (*s)
|
switch (*s)
|
||||||
{
|
{
|
||||||
case esc:
|
case esc:
|
||||||
buffer.printf("\\x%02x", (*++s) & 0xff);
|
buffer.print("\\x%02x", (*++s) & 0xff);
|
||||||
break;
|
break;
|
||||||
case '\r':
|
case '\r':
|
||||||
buffer.append("\\r");
|
buffer.append("\\r");
|
||||||
@ -655,7 +655,7 @@ printString(StreamBuffer& buffer, const char* s)
|
|||||||
buffer.append("\\\\");
|
buffer.append("\\\\");
|
||||||
break;
|
break;
|
||||||
case format_field:
|
case format_field:
|
||||||
buffer.printf("%%(%s)", ++s);
|
buffer.print("%%(%s)", ++s);
|
||||||
while (*s++);
|
while (*s++);
|
||||||
s += extract<unsigned short>(s); // skip fieldaddress
|
s += extract<unsigned short>(s); // skip fieldaddress
|
||||||
goto format;
|
goto format;
|
||||||
@ -670,7 +670,7 @@ format: {
|
|||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
if ((*s & 0x7f) < 0x20 || (*s & 0x7f) == 0x7f)
|
if ((*s & 0x7f) < 0x20 || (*s & 0x7f) == 0x7f)
|
||||||
buffer.printf("\\x%02x", *s & 0xff);
|
buffer.print("\\x%02x", *s & 0xff);
|
||||||
else
|
else
|
||||||
buffer.append(*s);
|
buffer.append(*s);
|
||||||
}
|
}
|
||||||
@ -742,7 +742,7 @@ Protocol(const Protocol& p, StreamBuffer& name, int _line)
|
|||||||
int i;
|
int i;
|
||||||
const char* nextparameter;
|
const char* nextparameter;
|
||||||
parameter[0] = protocolname();
|
parameter[0] = protocolname();
|
||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < 9; i++)
|
||||||
{
|
{
|
||||||
debug("StreamProtocolParser::Protocol::Protocol $%d=\"%s\"\n",
|
debug("StreamProtocolParser::Protocol::Protocol $%d=\"%s\"\n",
|
||||||
i, parameter[i]);
|
i, parameter[i]);
|
||||||
|
@ -82,14 +82,14 @@ parse(const StreamFormat&, StreamBuffer& info,
|
|||||||
if (*c == 'f')
|
if (*c == 'f')
|
||||||
{
|
{
|
||||||
source = c;
|
source = c;
|
||||||
info.printf("%%0%uf", n);
|
info.print("%%0%uf", n);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* look for nanoseconds %N of %f */
|
/* look for nanoseconds %N of %f */
|
||||||
if (*source == 'N' || *source == 'f')
|
if (*source == 'N' || *source == 'f')
|
||||||
{
|
{
|
||||||
info.printf("%%09f");
|
info.print("%%09f");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* look for seconds with fractions like %.3S */
|
/* look for seconds with fractions like %.3S */
|
||||||
@ -100,7 +100,7 @@ parse(const StreamFormat&, StreamBuffer& info,
|
|||||||
if (toupper(*c) == 'S')
|
if (toupper(*c) == 'S')
|
||||||
{
|
{
|
||||||
source = c;
|
source = c;
|
||||||
info.printf("%%%c.%%0%uf", *c, n);
|
info.print("%%%c.%%0%uf", *c, n);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user