new checksums added
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
* StreamDevice Support *
|
* StreamDevice Support *
|
||||||
* *
|
* *
|
||||||
* (C) 1999 Dirk Zimoch (zimoch@delta.uni-dortmund.de) *
|
* (C) 1999 Dirk Zimoch (zimoch@delta.uni-dortmund.de) *
|
||||||
* (C) 2006 Dirk Zimoch (dirk.zimoch@psi.ch) *
|
* (C) 2006-2018 Dirk Zimoch (dirk.zimoch@psi.ch) *
|
||||||
* *
|
* *
|
||||||
* This is the checksum pseudo-converter of StreamDevice. *
|
* This is the checksum pseudo-converter of StreamDevice. *
|
||||||
* Please refer to the HTML files in ../doc/ for a detailed *
|
* Please refer to the HTML files in ../doc/ for a detailed *
|
||||||
@ -457,6 +457,36 @@ static unsigned int hexsum(const unsigned char* data, size_t len, unsigned int s
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Special TRIUMF version for the CPI RF Amplifier
|
||||||
|
static unsigned int CPI(const unsigned char * data, size_t len, unsigned int init)
|
||||||
|
{
|
||||||
|
unsigned long i = len * 32;
|
||||||
|
while (len--)
|
||||||
|
{
|
||||||
|
init += *data++;
|
||||||
|
}
|
||||||
|
init -= i;
|
||||||
|
init %= 95;
|
||||||
|
init += 32;
|
||||||
|
return init;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Leybold Graphix uses a strange sum (= notsum + fix):
|
||||||
|
// "CRC = 255 - [(Byte sum of all preceding characters) mod 256]
|
||||||
|
// If this value is lower than 32 (control character of the ASCII code),
|
||||||
|
// then 32 must be added."
|
||||||
|
|
||||||
|
static unsigned int leybold(const unsigned char* data, size_t len, unsigned int sum)
|
||||||
|
{
|
||||||
|
while (len--)
|
||||||
|
{
|
||||||
|
sum += *data++;
|
||||||
|
}
|
||||||
|
sum = ~sum;
|
||||||
|
if (sum < 32) sum+=32;
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
struct checksum
|
struct checksum
|
||||||
{
|
{
|
||||||
const char* name;
|
const char* name;
|
||||||
@ -491,7 +521,9 @@ static checksum checksumMap[] =
|
|||||||
{"crc32r", crc_0x04C11DB7_r, 0xFFFFFFFF, 0xFFFFFFFF, 4}, // 0xCBF43926
|
{"crc32r", crc_0x04C11DB7_r, 0xFFFFFFFF, 0xFFFFFFFF, 4}, // 0xCBF43926
|
||||||
{"jamcrc", crc_0x04C11DB7_r, 0xFFFFFFFF, 0x00000000, 4}, // 0x340BC6D9
|
{"jamcrc", crc_0x04C11DB7_r, 0xFFFFFFFF, 0x00000000, 4}, // 0x340BC6D9
|
||||||
{"adler32", adler32, 0x00000001, 0x00000000, 4}, // 0x091E01DE
|
{"adler32", adler32, 0x00000001, 0x00000000, 4}, // 0x091E01DE
|
||||||
{"hexsum8", hexsum, 0x00, 0x00, 1} // 0x2D
|
{"hexsum8", hexsum, 0x00, 0x00, 1}, // 0x2D
|
||||||
|
{"cpi", CPI, 0x00, 0x00, 1}, // 0x7E
|
||||||
|
{"leybold", leybold, 0x00, 0x00, 1}, // 0x22
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned int mask[5] = {0, 0xFF, 0xFFFF, 0xFFFFFF, 0xFFFFFFFF};
|
static unsigned int mask[5] = {0, 0xFF, 0xFFFF, 0xFFFFFF, 0xFFFFFFFF};
|
||||||
|
15
streamApp/checksums.cmd
Executable file
15
streamApp/checksums.cmd
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
exec O.$EPICS_HOST_ARCH/streamApp $0
|
||||||
|
dbLoadDatabase "O.Common/streamApp.dbd"
|
||||||
|
streamApp_registerRecordDeviceDriver
|
||||||
|
|
||||||
|
drvAsynIPPortConfigure "terminal", "localhost:40000"
|
||||||
|
|
||||||
|
dbLoadRecords checksums.db
|
||||||
|
|
||||||
|
#log debug output to file
|
||||||
|
#streamSetLogfile StreamDebug.log
|
||||||
|
var streamError 1
|
||||||
|
|
||||||
|
iocInit
|
||||||
|
#var streamDebug 1
|
7
streamApp/checksums.db
Normal file
7
streamApp/checksums.db
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
record (stringout, "DZ:checksums")
|
||||||
|
{
|
||||||
|
field (DTYP, "stream")
|
||||||
|
field (OUT, "@checksums.proto write terminal")
|
||||||
|
field (VAL, "123456789")
|
||||||
|
field (PINI, "YES")
|
||||||
|
}
|
37
streamApp/checksums.proto
Normal file
37
streamApp/checksums.proto
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
Terminator = NL;
|
||||||
|
|
||||||
|
# Output string, checksum name and checksum value
|
||||||
|
# Format checksums as ascii hex (%0 flag)
|
||||||
|
# Ignore the 12 chars (.12) between the sting (%s) and the checksum (%<...)
|
||||||
|
|
||||||
|
write {
|
||||||
|
out "%s sum %0.12<sum>";
|
||||||
|
out "%s sum8 %0.12<sum8>";
|
||||||
|
out "%s ~sum %0.12<~sum>";
|
||||||
|
out "%s notsum %0.12<notsum>";
|
||||||
|
out "%s -sum %0.12<-sum>";
|
||||||
|
out "%s negsum %0.12<negsum>";
|
||||||
|
out "%s sum16 %0.12<sum16>";
|
||||||
|
out "%s sum32 %0.12<sum32>";
|
||||||
|
out "%s xor %0.12<xor>";
|
||||||
|
out "%s xor8 %0.12<xor8>";
|
||||||
|
out "%s xor7 %0.12<xor7>";
|
||||||
|
out "%s crc8 %0.12<crc8>";
|
||||||
|
out "%s ccitt8 %0.12<ccitt8>";
|
||||||
|
out "%s crc16 %0.12<crc16>";
|
||||||
|
out "%s crc16r %0.12<crc16r>";
|
||||||
|
out "%s modbus %0.12<modbus>";
|
||||||
|
out "%s ccitt16 %0.12<ccitt16>";
|
||||||
|
out "%s ccitt16a %0.12<ccitt16a>";
|
||||||
|
out "%s ccitt16x %0.12<ccitt16x>";
|
||||||
|
out "%s crc16c %0.12<crc16c>";
|
||||||
|
out "%s xmodem %0.12<xmodem>";
|
||||||
|
out "%s crc32 %0.12<crc32>";
|
||||||
|
out "%s crc32r %0.12<crc32r>";
|
||||||
|
out "%s jamcrc %0.12<jamcrc>";
|
||||||
|
out "%s adler32 %0.12<adler32>";
|
||||||
|
out "%s adler32b %0.12<adler32b>";
|
||||||
|
out "%s hexsum8 %0.12<hexsum8>";
|
||||||
|
out "%s cpi %0.12<cpi>";
|
||||||
|
out "%s leybold %0.12<leybold>";
|
||||||
|
}
|
@ -20,6 +20,11 @@ record (stringout, "$(P):request")
|
|||||||
record (stringin, "$(P):reply")
|
record (stringin, "$(P):reply")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
record (stringout, "$(P):checksum")
|
||||||
|
{
|
||||||
|
field (DTYP, "stream")
|
||||||
|
field (OUT, "@test.proto checksum($(CHKSUM=sum)) terminal")
|
||||||
|
}
|
||||||
record (stringin, "$(P):spy")
|
record (stringin, "$(P):spy")
|
||||||
{
|
{
|
||||||
field (DTYP, "stream")
|
field (DTYP, "stream")
|
||||||
@ -134,3 +139,4 @@ record (waveform, "$(P):spybin")
|
|||||||
field (NELM, "2000")
|
field (NELM, "2000")
|
||||||
field (SCAN, "I/O Intr")
|
field (SCAN, "I/O Intr")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,3 +23,6 @@ spybin {
|
|||||||
extraInput=ignore;
|
extraInput=ignore;
|
||||||
in "%r";
|
in "%r";
|
||||||
}
|
}
|
||||||
|
checksum {
|
||||||
|
out "%s %0.1<\$1>";
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user