21

Is there a simple way of redirecting serial port output to a file, that I can put into place on a test Windows desktop system without changing any code?

I'm trying to debug a problem in a serial receipt printer module and I don't have the real device handy today. I don't want to start making any changes to the code if I can help it, I just want to capture what is currently being output at the moment so that I can review it in a file.

It's Windows XP, if that makes any difference.

2

8 Answers 8

41

Another option is through command line:

type com1: >> data.log
7
  • 6
    Just tried this, and it works. Why is the least-simple answer the accepted one? This answer right here doesn't need any programs to be installed; It just works with what comes with the Windows command line.
    – E.T.
    Commented Oct 25, 2013 at 18:30
  • 1
    @E.T. maybe people are scared of hairy chested mode
    – Namphibian
    Commented Mar 29, 2016 at 13:00
  • 2
    This works only in big chunks and with up to 20s delay. Commented Jun 30, 2016 at 12:18
  • 1
    How to adress serial port with a number greater than 4? Commented Dec 22, 2018 at 15:45
  • 2
    If you want to set the baud rate, data bits or things like that just run the mode command beforehand. learn.microsoft.com/en-us/windows-server/administration/… Commented Aug 27, 2020 at 13:39
8

Another option: Use putty and turn on logging.

0
6

A quick google led me to RS232 Data Logger - I haven't tried it, but if it does what it says on the tin it should be OK for you. Edit: it appears to be incoming, not outgoing. Might be worth a try though :-)

3
  • 1
    Thanks Dan. It let me to their Serial Port Monitor, which is capturing something. However I didn't factor that the app/com port component itself would expect some kind of feedback from the device before it would work - it might be that this whole approach is a bust without the receipt printer itself. :-)
    – robsoft
    Commented Jun 27, 2009 at 12:51
  • Serial Port Monitor did the trick Dan. I was able to watch output going to the receipt printer even though it wasn't plugged in, once I'd sussed it out a bit. Many thanks!
    – robsoft
    Commented Jun 28, 2009 at 8:37
  • 1
    This is not a logger, this just is a RS232 terminal: during logging the port is busy, so you can not log the transaction from host to host. This is just a serial port terminal to file.
    – Tobia
    Commented Aug 25, 2014 at 9:46
2

You could run the printer module in a VM. VMWare allows you to redirect serial ports to files and named pipes.

1
  • Oh wow - how cool. The machine is already a VM - I didn't realise I could redirect the serial comms that way. I'll give that a try - many thanks!
    – robsoft
    Commented Jun 27, 2009 at 13:42
1

Similar to VMWare, Virtual PC (& Virtual Server) can also redirect a COM port to a text file and setup is very simple.

0

I think in the control pandel, printers, you can add manual printer and install dummay one So you can printing to a file for example

1
  • Thanks for the suggestion. I originally tried something like this but found that my app wouldn't talk to the com port if it thought it was involved with a Windows printer. I'm not ruling out that I was doing something wrong, though!
    – robsoft
    Commented Jun 28, 2009 at 8:41
-1

If you are developer use Serial Port component from .NET or if you don't are a developer and only want get information to file use windows HyperTerminal

-2

I don't know if you can redirect COM ports but you can use com0com for that kind of job.

For example, you can pair (COM1, COM2), so you can write to COM1 and read from COM2.

Not the answer you're looking for? Browse other questions tagged or ask your own question.