Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Hyperterminal- Enter Key <CR> <LF>

Status
Not open for further replies.

dknguyen

Well-Known Member
Most Helpful Member
When I press enter on my keyboard, does it generate a <CR> or a <LF>? or both? And in what order?

I am writing some PIC and PC stuff for them to communicate with each other over the UART, but I also need to make the PIC compatible with a regular hyperterminal window where users can manually enter things.
 
dknguyen said:
When I press enter on my keyboard, does it generate a <CR> or a <LF>? or both? And in what order?

I am writing some PIC and PC stuff for them to communicate with each other over the UART, but I also need to make the PIC compatible with a regular hyperterminal window where users can manually enter things.
In Hyperterminal's options you can set how it behaves. I don't think you can change the order though. It would be CR - LF, I think.
 
use PortMon software to debug communication with Com ports.
Created by Sysinternals and TOOK OVER by microsoft. No surprise there.
https://technet.microsoft.com/en-us/sysinternals/bb896644.aspx

Get very good with this software or any com port debugging software. ODOA is pushed out the comport for every Enter key pressed. CR first LF second.
 
Last edited:
I agree with Futz--it's not determined by the keyboard but by the terminal program. File -> Properties -> Settings -> ASCII Setup in Hyperterminal. The keyboard itself just sends 0x1c to the PC.

I can't think of any reason you'd want to send the LF but maybe you have one. If sent it's always CR/LF, not LF/CR.


Torben

[Edit: Forgetting my PC hardware in my old age. Keyboard sends 0x5a; BIOS translates to 0x1c. Dang.]
 
Last edited:
Torben said:
I can't think of any reason you'd want to send the LF but maybe you have one.

Quite simple, CR returns the print head to the start of the line, and LF feeds the paper up one line. If you do CR on it's own the paper doesn't feed through, and you can over-print on the same line.

It's really all based on paper printers (probably teletypes), but terminal programs are designed to emulate those - generally they are configurable to accept just CR and internally add a LF as well. If you have the terminal program configured in that way, sending the normal CR/LF will produce double-spacing.

Back in the DOS days I wrote various terminal and communication prgrammes, including my own Packet Radio program I used to use.
 
Nigel Goodwin said:
Quite simple, CR returns the print head to the start of the line, and LF feeds the paper up one line. If you do CR on it's own the paper doesn't feed through, and you can over-print on the same line.

It's really all based on paper printers (probably teletypes), but terminal programs are designed to emulate those - generally they are configurable to accept just CR and internally add a LF as well. If you have the terminal program configured in that way, sending the normal CR/LF will produce double-spacing.

Back in the DOS days I wrote various terminal and communication prgrammes, including my own Packet Radio program I used to use.

Right, I know that much. Perhaps I should have been more clear and said "for PIC communication". Unless he's writing a line printer driver for the PIC, in which case it would be useful. I do miss the days of writing 8086 assembler programs and debug scripts for all the stuff which was missing from DOS.

About 17 years ago my .sig read 'Real programmers use "copy con progname.exe"'. :)


Torben
 
Torben said:
About 17 years ago my .sig read 'Real programmers use "copy con progname.exe"'. :)
Torben
Mel was a real programmer. I do remember checking modems by doing 'copy con com1:'.

Mike.
 
Pommie said:
Mel was a real programmer. I do remember checking modems by doing 'copy con com1:'.

Mike.


I remember that story--always loved it. I'd never compare myself to that guy. And I never knew anyone who actually did a 'copy con progname.exe' but I did have fun with writing short debug scripts in hex. It was the geek equivalent of what the jocks were doing in the gym: building skills (but really just showing off).


Torben
 
Just printing CR on its own is often handy on a terminal because it can be used to move the cursor back to the beginning of the line and overwrite the display.
 
Back in the teletype days a CR without a LF was quite handy for printing password fields. You would print something like #$@*OM on top of itself (with each character repeated for each character position) for the password field leaving a dark box. Then when you typed in your password, no one could read what you typed. The automatic linefeed was a pain because you would have to tear your password out of the paper so it would not be found in the trash.

Another neat trick was to space out several characters and print the last character on the line, two backspaces, then the next to the last character, etc., to print a line backwards.

And don't forget control-G (BEL) and RUBOUT.

Linefeed could also be used by itself to advance the paper without returning the carriage so you don't need a bunch of blanks at the beginning of a line.

(I think I got off topic.)
Dale
 
DSGarcia said:
And don't forget control-G (BEL) and RUBOUT.

I used to use those for DOS programs in order to beep (duh) or, with rubout, to show progress indicators with "spinners" (printing / - \ | repeatedly with rubouts between) and percent-done numbers or such.

Never had to code for a teletype myself, though.


Torben
 
I made a comment the other day when there was aproblem with a printer that maybe copy con to printer could be used to bypass the driver ..... DOS whats that
 
Super_voip said:
I made a comment the other day when there was aproblem with a printer that maybe copy con to printer could be used to bypass the driver ..... DOS whats that

Unfortunately it would be very rare for a printer to work under DOS, the reason for the rapid drop in printer prices is due to moving the main processing from the printer to the Windows PC - this has made printer prices plummet, but means you can't copy con to PRN anymore :(
 
If you did that on an NT machine, then it would just pass it to the printer dirver.

I think it's quite silly that the processing has moved from the printer to the PC, when the reverse has happened with sound and graphics cards. I'd rather pay more for my printer, have the print jobs print faster without slowing down my PC and be able to use it under any operating system without installing a driver.
 
Hero999 said:
If you did that on an NT machine, then it would just pass it to the printer dirver.

I think it's quite silly that the processing has moved from the printer to the PC, when the reverse has happened with sound and graphics cards. I'd rather pay more for my printer, have the print jobs print faster without slowing down my PC and be able to use it under any operating system without installing a driver.

It's all down to price, would you sooner pay £99 for a laser printer or £699 for one, it's not like the difference is only slight.
 
Pommie said:
I do remember checking modems by doing 'copy con com1:'.

This doesn't work on Windows XP, though, it keeps on echoing whatever I type when I press ENTER, and doesn't show the modem response, nor does the modem seem to react to it (pressing ATDTxxxxx doesn't dial the number, otherwise I should hear the dial tone from the modem speaker), . When I press Ctrl-C to terminate it says

"The I/O operation has been aborted because of either a thread exit or an application request."

However, this reminds me of the first time I made my modem dial a number using Pascal by writing AT commands to its port. And also my first time using TERM95 (a terminal utility that comes with Norton Commander, any one still remember?) to dial to my friend's place and share my files. It was pretty slow and also cost a lot as we forget to disconnect the line afterwards...:D
 
I wouldn't believe the difference would be as large as you say. I'd rather pay £150 for a laser printer that prints faster, especially for larger print jobs.
 
Hero999 said:
I wouldn't believe the difference would be as large as you say. I'd rather pay £150 for a laser printer that prints faster, especially for larger print jobs.

It's not going to be that cheap, essentially you're adding a PC inside the printer, a laser printer has always needed considerable processing power and lot's of memory.

Admittedly some of the huge reduction in prices has come from making them cheaper, but much is down to moving most of the processing and memory from the printer to the PC.

Assuming you could find such a printer these days?, it's likely to be a fairly high-end one, with a suitable high price.

One source might be postscript printers?, which accept an ASCII text description file and generate the page accordingly?.
 
Status
Not open for further replies.

Latest threads

Back
Top