Compare commits

...

6 Commits

Author SHA1 Message Date
9049baf730 report protocol name with original case 2011-07-28 12:39:11 +00:00
050a165a82 bugfix: had stale fieldAddress under some circumstances 2011-07-28 12:08:39 +00:00
1428b85a34 must find a way to generate this 2011-07-20 08:33:19 +00:00
e4f8a6ed40 fix endless loop when port does not support EOS 2011-07-20 08:32:09 +00:00
5a5b42cb67 test reserve() 2011-07-20 08:31:10 +00:00
e62553eca6 input tests added 2011-07-20 08:30:38 +00:00
6 changed files with 115 additions and 28 deletions

View File

@ -739,38 +739,44 @@ readHandler()
streameos = getInTerminator(streameoslen);
deveos = streameos;
deveoslen = streameoslen;
if (streameos) do // streameos == NULL means: don't change eos
if (streameos) // streameos == NULL means: don't change eos
{
asynStatus status;
status = pasynOctet->getInputEos(pvtOctet,
pasynUser, oldeos, sizeof(oldeos)-1, &oldeoslen);
if (status != asynSuccess)
{
oldeoslen = -1;
// No EOS support?
}
// device (e.g. GPIB) might not accept full eos length
if (pasynOctet->setInputEos(pvtOctet, pasynUser,
deveos, deveoslen) == asynSuccess)
{
#ifndef NO_TEMPORARY
if (ioAction != AsyncRead)
if (streameos[0])
{
debug("AsynDriverInterface::readHandler(%s) "
"input EOS set to %s\n",
clientName(),
StreamBuffer(deveos, deveoslen).expand()());
error("%s: warning: No input EOS support.\n",
clientName());
}
oldeoslen = -1;
} else do {
// device (e.g. GPIB) might not accept full eos length
if (pasynOctet->setInputEos(pvtOctet, pasynUser,
deveos, deveoslen) == asynSuccess)
{
#ifndef NO_TEMPORARY
if (ioAction != AsyncRead)
{
debug("AsynDriverInterface::readHandler(%s) "
"input EOS set to %s\n",
clientName(),
StreamBuffer(deveos, deveoslen).expand()());
}
#endif
break;
}
deveos++; deveoslen--;
if (!deveoslen)
{
error("%s: warning: pasynOctet->setInputEos() failed: %s\n",
clientName(), pasynUser->errorMessage);
}
} while (deveoslen);
break;
}
deveos++; deveoslen--;
if (!deveoslen)
{
error("%s: warning: pasynOctet->setInputEos() failed: %s\n",
clientName(), pasynUser->errorMessage);
}
} while (deveoslen);
}
int bytesToRead = peeksize;
long buffersize;

View File

@ -650,9 +650,12 @@ formatOutput()
unsigned short addrlen = extract<unsigned short>(commandIndex);
fieldAddress.set(commandIndex, addrlen);
commandIndex += addrlen;
goto normal_format;
}
case StreamProtocolParser::format:
{
fieldAddress.clear();
normal_format:
// code layout:
// formatstring <eos> StreamFormat [info]
formatstring = commandIndex;
@ -696,7 +699,6 @@ formatOutput()
name(), formatstr.expand()());
return false;
}
fieldAddress.clear();
continue;
}
case StreamProtocolParser::whitespace:
@ -1169,9 +1171,12 @@ matchInput()
unsigned short addrlen = extract<unsigned short>(commandIndex);
fieldAddress.set(commandIndex, addrlen);
commandIndex += addrlen;
goto normal_format;
}
case StreamProtocolParser::format:
{
fieldAddress.clear();
normal_format:
int consumed;
// code layout:
// formatstring <eos> StreamFormat [info]
@ -1310,7 +1315,6 @@ matchInput()
return false;
}
// matchValue() has already removed consumed bytes from inputBuffer
fieldAddress.clear();
break;
}
case StreamProtocolParser::skip:
@ -1332,12 +1336,12 @@ matchInput()
while (commandIndex[i] >= ' ') i++;
if (!(flags & AsyncMode) && onMismatch[0] != in_cmd)
{
error("%s: Input \"%s%s\" too short.",
error("%s: Input \"%s%s\" too short.\n",
name(),
inputLine.length() > 20 ? "..." : "",
inputLine.expand(-20)());
#ifndef NO_TEMPORARY
error(" No match for \"%s\"\n",
error("No match for \"%s\"\n",
StreamBuffer(commandIndex-1,i+1).expand()());
#endif
}

View File

@ -227,7 +227,7 @@ getProtocol(const StreamBuffer& protocolAndParams)
return new Protocol(*protocol, name, 0);
}
error("Protocol '%s' not found in protocol file '%s'\n",
name(), filename());
protocolAndParams(), filename());
return NULL;
}

19
stream.dbd Normal file
View File

@ -0,0 +1,19 @@
device(aai,INST_IO,devaaiStream,"stream")
device(aao,INST_IO,devaaoStream,"stream")
device(ao,INST_IO,devaoStream,"stream")
device(ai,INST_IO,devaiStream,"stream")
device(bo,INST_IO,devboStream,"stream")
device(bi,INST_IO,devbiStream,"stream")
device(mbbo,INST_IO,devmbboStream,"stream")
device(mbbi,INST_IO,devmbbiStream,"stream")
device(mbboDirect,INST_IO,devmbboDirectStream,"stream")
device(mbbiDirect,INST_IO,devmbbiDirectStream,"stream")
device(longout,INST_IO,devlongoutStream,"stream")
device(longin,INST_IO,devlonginStream,"stream")
device(stringout,INST_IO,devstringoutStream,"stream")
device(stringin,INST_IO,devstringinStream,"stream")
device(waveform,INST_IO,devwaveformStream,"stream")
device(calcout,INST_IO,devcalcoutStream,"stream")
driver(stream)
variable(streamDebug, int)
registrar(streamRegistrar)

View File

@ -12,10 +12,26 @@ set records {
field (DTYP, "stream")
field (OUT, "@test.proto test1 device")
}
record (longin, "DZ:test2")
{
field (DTYP, "stream")
field (INP, "@test.proto test2 device")
}
record (longin, "DZ:test3")
{
field (DTYP, "stream")
field (INP, "@test.proto test3 device")
}
record (longin, "DZ:test4")
{
field (DTYP, "stream")
field (INP, "@test.proto test4 device")
}
}
set protocol {
Terminator = LF;
OutTerminator = LF;
MaxInput = 4;
test1 {
out "%r"; out "%.1r"; out "%.2r"; out "%.3r"; out "%.4r"; out "%.5r";
out "%#r"; out "%#.1r"; out "%#.2r"; out "%#.3r"; out "%#.4r"; out "%#.5r";
@ -23,6 +39,18 @@ set protocol {
out "%0r"; out "%01r"; out "%02r"; out "%03r"; out "%04r"; out "%05r";
out "%#0r"; out "%#01r"; out "%#02r"; out "%#03r"; out "%#04r"; out "%#05r";
};
test2 {
in "%04.4r";
out "%08x";
}
test3{
in "%#3r\?";
out "%08x";
}
test4{
in "%#03r\?";
out "%08x";
}
}
set startup {
@ -192,6 +220,35 @@ assure "\xef\x00\x00\n"
assure "\xef\x00\x00\x00\n"
assure "\xef\x00\x00\x00\x00\n"
ioccmd {dbpf DZ:test2.PROC 1}
send "\x01\x02\x03\x04"
assure "01020304\n"
ioccmd {dbpf DZ:test2.PROC 1}
send "\xde\xad\xbe\xef"
assure "deadbeef\n"
ioccmd {dbpf DZ:test2.PROC 1}
send "\x00\x00\x00\x00"
assure "00000000\n"
ioccmd {dbpf DZ:test3.PROC 1}
send "\x04\x03\x02\x01"
assure "00020304\n"
ioccmd {dbpf DZ:test3.PROC 1}
send "\xde\xad\xbe\xef"
assure "ffbeadde\n"
ioccmd {dbpf DZ:test3.PROC 1}
send "\x00\x00\x00\x00"
assure "00000000\n"
ioccmd {dbpf DZ:test4.PROC 1}
send "\x04\x03\x02\x01"
assure "00020304\n"
ioccmd {dbpf DZ:test4.PROC 1}
send "\xde\xad\xbe\xef"
assure "00beadde\n"
ioccmd {dbpf DZ:test4.PROC 1}
send "\x00\x00\x00\x00"
assure "00000000\n"
finish

View File

@ -48,6 +48,7 @@ int main () {
assert (haystack.find(needle) == 0);
haystack.clear();
assert (haystack.find(needle) == 0);
haystack.reserve(10000);
return 0;
}
EOF