1. 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.
    Dismiss Notice

Hyperterminal- Enter Key <CR> <LF>

Discussion in 'Microcontrollers' started by dknguyen, Mar 30, 2008.

  1. dknguyen

    dknguyen Well-Known Member

    Joined:
    May 6, 2006
    Messages:
    6,668
    Likes:
    64
    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.
     
  2. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    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.
     
  3. donniedj

    donniedj Banned

    Joined:
    Jan 16, 2004
    Messages:
    336
    Likes:
    3
    Location:
    So Cal
    use PortMon software to debug communication with Com ports.
    Created by Sysinternals and TOOK OVER by microsoft. No surprise there.
    http://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: Mar 30, 2008
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Torben

    Torben Well-Known Member

    Joined:
    Oct 6, 2006
    Messages:
    2,507
    Likes:
    34
    Location:
    B.C., Canada

    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: Mar 30, 2008
  6. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,216
    Likes:
    640
    Location:
    Derbyshire, UK
    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.
     
  7. Torben

    Torben Well-Known Member

    Joined:
    Oct 6, 2006
    Messages:
    2,507
    Likes:
    34
    Location:
    B.C., Canada
    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
     
  8. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,016
    Likes:
    317
    Location:
    Brisbane Australia
    ONLINE
    Mel was a real programmer. I do remember checking modems by doing 'copy con com1:'.

    Mike.
     
  9. Torben

    Torben Well-Known Member

    Joined:
    Oct 6, 2006
    Messages:
    2,507
    Likes:
    34
    Location:
    B.C., Canada

    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
     
  10. Hero999

    Hero999 Banned

    Joined:
    Apr 6, 2006
    Messages:
    14,902
    Likes:
    79
    Location:
    England
    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.
     
  11. DSGarcia

    DSGarcia New Member

    Joined:
    Nov 10, 2006
    Messages:
    250
    Likes:
    1
    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
     
  12. Torben

    Torben Well-Known Member

    Joined:
    Oct 6, 2006
    Messages:
    2,507
    Likes:
    34
    Location:
    B.C., Canada
    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
     
  13. Super_voip

    Super_voip New Member

    Joined:
    Jul 2, 2007
    Messages:
    340
    Likes:
    1
    Location:
    Brisbane, Australia
    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
     
  14. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,216
    Likes:
    640
    Location:
    Derbyshire, UK
    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 :(
     
  15. Hero999

    Hero999 Banned

    Joined:
    Apr 6, 2006
    Messages:
    14,902
    Likes:
    79
    Location:
    England
    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.
     
  16. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,216
    Likes:
    640
    Location:
    Derbyshire, UK
    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.
     
  17. mdanh2002

    mdanh2002 Member

    Joined:
    Sep 26, 2006
    Messages:
    439
    Likes:
    9
    Location:
    Singapore
    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
     
  18. Hero999

    Hero999 Banned

    Joined:
    Apr 6, 2006
    Messages:
    14,902
    Likes:
    79
    Location:
    England
    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.
     
  19. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,216
    Likes:
    640
    Location:
    Derbyshire, UK
    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?.
     

Share This Page