[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Read full 8-bit character from serial port?
Ron Kneusel <oneelkruns@hotmail.com> wrote:
> Thanks all for the many replies!
>
> I'm muddling along with the old IN#2 routine using QForth 2.2. It
> works most of the time but certain combinations of characters seem to
> cause other characters to be lost. I'm reading a simple packet of
> data, an address byte, a length (number of remaining bytes to read) and
> some data. Last two bytes are a CRC-16.
>
> For example, if I send:
>
> \x00\x03\x00\x99\xCF
>
> everything works fine. But, if I change the address to \x01:
>
> \x01\x03\x00\xAE\xFF
>
> the final \xFF doesn't get read. The software is waiting for 3
> additional bytes and if I hit the spacebar on the Apple IIgs it gets
> read as \xA0 and completes the input. Odd.
The firmware is treating this as an embedded command (which it doesn't
recognise). The serial firmware reacts to the Ctrl-A character (0x01) in
the I/O stream by expecting a numeric parameter and letter which
identify a command to the firmware, e.g. to change baud rate. Some
firmware (either the SSC, IIc or IIgs) also expects a CR to complete the
command. Another oddball sequence might result in unusual behaviour.
You can also change the command prefix to a different control character
by sending it straight after the Ctrl-A. I'd expect the above sequence
to change the command character to Ctrl-C (0x03) and delete those two.
You can put the firwmare into transparent mode (which makes it ignore
any subsequent Ctrl-A and transmit it as a normal character) by sending
Ctrl-A followed by "Z" (0x5A) (if I remember right). Restoring command
recognition requires reinitializing the serial firmware or sending a
special command via the control entry point.
I hadn't realised it did this on the input side as well as the output
side. You might need to do PR#2 as well, so you can send Ctrl-A Z then
your input stream should be unmolested.
> Unfortunately, I can't spent too much time fiddling with this. I just
> wanted to use the Apple a bit to help with a project but I can't
> justify loads of time and then charge the client for it.
--
David Empson
dempson@actrix.gen.nz