End of File / End of Block?

End of File / End of Block?

Post by dp » Sat, 05 Jan 2002 06:07:42



I'm trying to get a PC Running Linux Redhat 7.1 to communicate with a Okuma
Lathe.  It has a friendly little CNC controller on it which for the most
part speaks perfect ASCII.

I can send a file with cat /home/file > /dev/ttyS1 just fine, the file goes,
the CNC thinks that the file is done coming.  When you go to run the program
all is well.

The problem is when I send data from the CNC to the Linux box.  For some
reason, the data doesn't seem to terminate from that end.  I've looked at
the end of the file with a hex editor, and the results are:

Ascii/Hex
2 / 32
. / 0D
. / 0A
% / 25
. / 00
. / 14

It looks like 14 is the termination character?  Eof?

I have tried setting the end of file character with stty for this port
(/dev/ttyS1) so eof is 14, but it doesn't seem to work.

Any help would be appreciated.  Thanks.

-Brian

 
 
 

End of File / End of Block?

Post by Walter Haber » Sat, 05 Jan 2002 08:03:11



Quote:> ... cut ...
> It looks like 14 is the termination character?  Eof?

> I have tried setting the end of file character with stty for this port
> (/dev/ttyS1) so eof is 14, but it doesn't seem to work.

EOF in ASCII is 26

 
 
 

End of File / End of Block?

Post by Matthew Mill » Sat, 05 Jan 2002 08:56:07



>EOF in ASCII is 26

I don't think that's correct. DOS uses ^Z (026D) for EOF, but Unix uses ^D
(004D), the ASCII EOT (end-of-transmission) character. As far as I know,
there's no standard ASCII EOF.

--

Boston University Linux      ------>                <http://linux.bu.edu/>

 
 
 

End of File / End of Block?

Post by stan » Sat, 05 Jan 2002 09:36:49


Well,

if you are ambitious you could write a small program to read the tty.
This makes sense if all you want to do is get a file from the CNC and
you were using a LINUX command such as cat or od to read tfile.  All you
need to do is implement a loop that terminates when it gets the CNC
temination character.  Something like:

#include <stdio.h>

main(argc, argv)
int argc;
char *argv[];
{
        FILE *fp;
        int c;

        iif((fp=fopen("/dev/ttyS1", "r")) == (FILE *)NULL)
                exit(1);

        while((c=getc(fp)) != 0x14)
                putchar(c);

Quote:}

Of course you would probably want some error handling and the port might
need some additional initialization, but the above is the basic
concept.  Just put in a file called myread.c and compile it by typing:

cc -o myread myread.c

You might get lucky and it will just work out-right or you might need to
set some options - do a man on termios for additional info:

man termios

Stan



> >EOF in ASCII is 26

> I don't think that's correct. DOS uses ^Z (026D) for EOF, but Unix uses ^D
> (004D), the ASCII EOT (end-of-transmission) character. As far as I know,
> there's no standard ASCII EOF.

> --

> Boston University Linux      ------>                <http://linux.bu.edu/>

 
 
 

End of File / End of Block?

Post by bd » Sat, 05 Jan 2002 09:44:59



> I'm trying to get a PC Running Linux Redhat 7.1 to communicate with a
> Okuma
> Lathe.  It has a friendly little CNC controller on it which for the most
> part speaks perfect ASCII.

> I can send a file with cat /home/file > /dev/ttyS1 just fine, the file
> goes,
> the CNC thinks that the file is done coming.  When you go to run the
> program all is well.

> The problem is when I send data from the CNC to the Linux box.  For some
> reason, the data doesn't seem to terminate from that end.  I've looked at
> the end of the file with a hex editor, and the results are:

> Ascii/Hex
> 2 / 32
> . / 0D
> . / 0A
> % / 25
> . / 00
> . / 14

> It looks like 14 is the termination character?  Eof?

> I have tried setting the end of file character with stty for this port
> (/dev/ttyS1) so eof is 14, but it doesn't seem to work.

> Any help would be appreciated.  Thanks.

> -Brian

Try 20, 14 is in hex.

--
Failure is not an option. It comes bundled with your Microsoft product.

Visualize whirled peas.

 
 
 

End of File / End of Block?

Post by Walter Haber » Sat, 05 Jan 2002 10:10:41


Well, yes, one should not look in a hurry in his own notes that come from a
time programming in C under OS/2 and give a quick answer. You got me. Sorry,
I did not mean to misinform anyone.
Walter.




> >EOF in ASCII is 26

> I don't think that's correct. DOS uses ^Z (026D) for EOF, but Unix uses ^D
> (004D), the ASCII EOT (end-of-transmission) character. As far as I know,
> there's no standard ASCII EOF.

> --

> Boston University Linux      ------>                <http://linux.bu.edu/>

 
 
 

End of File / End of Block?

Post by Villy Kru » Sat, 05 Jan 2002 20:23:13


On 3 Jan 2002 23:56:07 GMT,


>>EOF in ASCII is 26

>I don't think that's correct. DOS uses ^Z (026D) for EOF, but Unix uses ^D
>(004D), the ASCII EOT (end-of-transmission) character. As far as I know,
>there's no standard ASCII EOF.

Furthermore, ctrl-D in unix functions as EOF only if typed from the keyboard,
and that only if the tty device is in canonical mode.

EOF on a TCP connection is received when the sending side sends a FIN package,
which usualy happens when the socket is closed.

Villy

 
 
 

End of File / End of Block?

Post by Sandgrope » Sat, 05 Jan 2002 22:23:31



>I'm trying to get a PC Running Linux Redhat 7.1 to communicate with a
Okuma
>Lathe.  It has a friendly little CNC controller on it which for the
most
>part speaks perfect ASCII.

>I can send a file with cat /home/file > /dev/ttyS1 just fine, the file
goes,
>the CNC thinks that the file is done coming.  When you go to run the
program
>all is well.

>The problem is when I send data from the CNC to the Linux box.  For
some
>reason, the data doesn't seem to terminate from that end.  I've looked
at
>the end of the file with a hex editor, and the results are:

>Ascii/Hex
>2 / 32
>. / 0D
>. / 0A
>% / 25
>. / 00
>. / 14

Check out the man pages for ascii. ( man ascii )

The last character in the display is the Hex number 14 , which is for
DC4 .

DC4 = Device Control 4
ETX = End of Text
EOT = End of Transmission ( control - c )
SUB = Substitute - Control-Z , EOF

You will possibly need to use either  ETX , EOT or SUB

Oct   Dec   Hex   Char
------------------------------
000   0     00    NUL '\0'
001   1     01    SOH
002   2     02    STX
003   3     03    ETX
004   4     04    EOT
005   5     05    ENQ
006   6     06    ACK
007   7     07    BEL '\a'
010   8     08    BS  '\b'
011   9     09    HT  '\t'
012   10    0A   LF  '\n'
013   11    0B   VT  '\v'
014   12    0C   FF  '\f'
015   13    0D   CR  '\r'

021   17    11    DC1
022   18    12    DC2
023   19    13    DC3
024   20    14    DC4

032   26    1A    SUB

Sandgroper
-----------------------------------
Remove  Quokkas for Email

 
 
 

End of File / End of Block?

Post by Lew Pitch » Sat, 05 Jan 2002 22:45:29





[snip]
>>The problem is when I send data from the CNC to the Linux box.  For
>some
>>reason, the data doesn't seem to terminate from that end.  I've looked
>at
>>the end of the file with a hex editor, and the results are:

>>Ascii/Hex
>>2 / 32
>>. / 0D
>>. / 0A
>>% / 25
>>. / 00
>>. / 14

>Check out the man pages for ascii. ( man ascii )

>The last character in the display is the Hex number 14 , which is for
>DC4 .

>DC4 = Device Control 4

AKA "Punch Off", to turn the paper tape punch off
DC1 is "Reader On", to turn the paper tape reader on,
DC2 is "Reader Off", to turn the paper tape reader off,
DC3 is "Punch On", to turn the paper tape punch on

Reader/Punch On/Off come from an age when terminal devices were implemented as
paper-using printer/keyboards, and the king was the ASR33 from Teletype Corp.
The ASR33 had a paper tape punch and paper tape reader attached to it's side,
and (with the printing of suitable control characters), a computer could turn on
and off these two devices. When on, the paper tape reader would substitute for
the keyboard, sending characters from the paper tape input down to the computer.
When on, the paper tape punch would accept characters from the computer, and
punch them into a paper tape roll (which was used as offline storage, and could
be read by the paper tape reader).

Your CNC device thinks that it's talking to a dumb ASR33-like terminal device.

Quote:>ETX = End of Text

ETX (0x03) is ^C (control - c)

Quote:>EOT = End of Transmission ( control - c )

EOT (0x04) is ^D (control - d)
In most Unixes, including Linux, EOT is the default "EOF" for cooked and cbreak
data (i.e. data received from a terminal).

Quote:>SUB = Substitute - Control-Z , EOF

Not "EOF" in Linux, unless you've set the tty parameters explicitly for it
However, ^Z is hardcoded as the terminal EOF in CP/M derivatives, including
MSDOS and MSWindows DOS emulation.

[snip]

To the OP:

Before you start your CNC->Linux download, change the EOF character on
/dev/ttyS1 to the DC4 character ('man stty'). You can change it back after the
CNC device has finished with the line, but in the mean time, the DC4 from the
CNC will act as EOF to the Linux terminal.

Lew Pitcher
IT Consultant, Development Services
Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employers')

 
 
 

1. Does end-of-file (end-of-page) key work in Netscape 4.03 (LinuxDoes end-of-file (end-of-page) key work in Netscape 4.03 (Linux

For Netscape 4.03 (stand-alone) under Linux:

I have tried Ctrl-PageDown, Alt-PageDown, Ctrl-End,
Alt-End, Meta->  (Esc->) and many other keystroke combinations
to go the end of web page.

Is there a keystroke to do this that perhaps I haven't tried?

If not, is there a way to fix it perhaps with the addition
of a line in preferences.js or .Xdefaults ?

(Of course, I would like to be able to jump to the top of
the page, also.)

If it's not fixable in 4.03, do the latest versions fix this?

Thanks

P.S. If there's a more appropriate group to post this
message in, please let me know.

NOTE-- Junk mail trap:
To e-mail me, please remove the following word from the
address above: system

2. 2.5.44-ac1 : drivers/media/video/adv7175.c

3. end-to-end security

4. SPARCprinter & Solaris 2.3

5. driver bcopy is swapping bytes end to end

6. xv related matters !?!?!?!

7. Netscape front-end for end-users

8. Remove main panel

9. Toronto-Unix System Administrator-Intermediate -Contract starts end of June to end of year, possible extention

10. Automatic Anon. FTP or End a pipe without ending input

11. Proxy Bad Gateway (502) Errors between front-end ssl and back-end mod_perl server!

12. If you could get all the WinTrolls to lie end to end ...

13. Video Cards Final choice Higher end TNT2 or lower end GeForce