Re: Assigning output from LINEOUT to a variable



On 2006-06-20, toastyboy@xxxxxxxxxxxxxx <toastyboy@xxxxxxxxxxxxxx> wrote:
: Regarding parsing the output, here is what I would simply expect to see
: either a 1 or a 0 (depending on the state of the input) followed by a #
: on a new line.
:
: (The # is the command prompt on this device if you like)
:
: See the below extract from an interactive session:
:
: #
: #I1
: 1
: #I2
: 1
: #I3
: 1
: #I4
: 0
: #
:
: What I want is either to set the 0 or 1 as a variable and then based on
: this write out a file with the 0 or 1 in it, or (better still) write
: the 0 or 1 out to a file directly.
:
You want to send a command to this device, get back a single-character
response, and write the response to a file. This is seemingly
straightforward, but there's a bit more to it, because maybe the device echoes
what you send, and since the single-character responses really come with some
other stuff, such as carriage returns and linefeeds. What do you want to go
into your file -- a single digit, or the digit followed by carriage return
and/or linfeed?

Let's say you want to store <digit><CR><LF>. Then the above sequence
would be programmed something like this:

clear input ; start with a clean INPUT buffer
output \13 ; send a carriage return (\13) to make a prompt appear
input 5 \# ; wait 5 sec for the '#' prompt
if fail stop 1 ; make sure we got it
output I1\13 ; Send "I1" and a carriage return

; Let's assume the devices echoes "I1<CR><LF>"

input 5 I1\13\10 ; Absorb the echo
if fail ... ; Do something if the echo does not appear
clear input ; clear the input buffer again
input 5 \10 ; Input everything up to a linefeed
if fail ...

; At this point \v(input) should contain the resonse.
; Now you can write it to a file.

fopen /write \%c somefilename
if fail ...
fwrite /line \%c \ftrim(\v(input))
fclose \%c

and so on for I2, I3, and I4. I didn't show what to do on failure,
that's up to you. Maybe there is some corrective action you can take.
You can loop and try again, whatever. The statement:

fwrite /line \%c \ftrim(\v(input))

trims the CRLF from the response, and then writes it to disk in native
format for a line, which is not necesarily text terminated by CRLF.

- Frank
.



Relevant Pages

  • Re: Regarding Acoustic Echo Cancellation with Subbanding
    ... response will fail during the traditional world. ... arrows are certain and other stale heros are varied, ... whenever Brian responds the immediate ...
    (sci.crypt)
  • Re: No Users List Starting Windows XP
    ... This is a copy of a post that I sent a while ago and below is a response ... The boot up stops at the windows logo ... Login to the Administrator account by typing the password for this ... and press ENTER at the command prompt. ...
    (microsoft.public.windowsxp.general)
  • Re: W2K3 Service w/ UNC Access, Local Disk Access, and DB Access
    ... > It should not fail, how did you specify your local account? ... >> Thanks for your response. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SMTP at Blueyonder must have changed.
    ... The fact that you're receiving an invalid response on the RCPT statement could be caused by a number of things: ... Connecting from an IP address that is not within the blueyonder address pool - in which case you would receive a 550 response after the RCPT command if connecting without authentication ... though it would be odd for this to only fail on the RCPT command. ...
    (uk.telecom)
  • Re: Cant empty recycle bin
    ... Despite the response I got, ... command prompt issue the following command: ... When I try to empty the recycle bin I get a message saying: ... Can't delete Dc30. ...
    (microsoft.public.windowsxp.help_and_support)

Loading