Experimental Physics and
| |||||||||||||||||
|
I finally realaized that the device was sending \n\r rather than what I expected \r\n. First point taken. Due to the fact that it echoes because drvAscii doesn't allow (or I didn't figure out how) to send strings without terminators, it sends more replies back than you send commands in. The solution to that part is is to eat all leading carriage returns and/or line feeds, with a custom read function (thanks Matt (Rippa), I used a skeleton of your getTrimmedFrame that you wrote for the Optomuxes). That bit of the code looks like this: if (chr == '\n' && idx==0) continue; if (chr == '\r' && idx==0) continue; It still left me with 2 more lines, both of which were too long (the first line was 120 characters long but had a lot of letters, parentheses and blanks in it which the data line I'm after doesn't, so: if ( chr == ')' ) continue; if ( chr == '(' ) continue; if ( chr == '>' ) continue; if ( chr == ' ' ) continue; if ( isalpha(chr) ) continue; (">" is the returned prompt) which left me with a too long line consisting of numbers, periods, commas, a % at the end, another \n\r and the data that I'm trying to get. Getting rid of that took this: if (chr == '.' && idx==0) continue; if (chr == ',' && idx==0) continue; if (chr == '0' && idx==0) continue; if (chr == '1' && idx==0) continue; if (chr == '2' && idx==0) continue; if (chr == '3' && idx==0) continue; if (chr == '4' && idx==0) continue; if (chr == '5' && idx==0) continue; if (chr == '6' && idx==0) continue; if (chr == '7' && idx==0) continue; if (chr == '8' && idx==0) continue; /* (there are no 9s in that string) */ /* eat the terminator after the '%' */ if (chr == '\n' && prevchr=='%') continue; if (chr == '\r' && prevchr=='%') continue; (and the implementation of a static prevchr). Why between the drvAscii debug output and the next record down it loses a few characters at the end I havent gotten at yet, and I'm not sure I really care (they contain the ambient temperature, pressure and humidity which we monitor elsewhere). But, this rather awkward to interface thing is giving me data now (well, almost. I still have to chop its return string up into numbers, but I'm as far as geting the string into the gensub as well). Don't know whether anybody wants to know at this point, but it may come in handy to somebody at some point. (Allan, I never got the <n>T do anything for me in this case, I presume because it (took me ages to realize) doesn't send \r\n but \n\r., and the last line comes out several seconds later) Aloha, Maren On Tue, 1 Jun 2010, Maren Purves wrote: Hi all,
| ||||||||||||||||
ANJ, 02 Sep 2010 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |