Question

I'm sending ESC/P codes (http://webpages.charter.net/dperr/links/esc_p83.htm) to an Epson LX-300 printer which is connected to the COM1 and the pc already has the correct driver installed because someone else needs it.

So i wrote this:

using System.IO.Ports;

public class EpsonPrint {

    private char esc = (char)27;
    private char ff = (char)12;

    public static void Main (string[] args) {
        new EpsonPrint();
    }

    public EpsonPrint() {
        SerialPort port = new SerialPort("COM1", 19200, Parity.None, 8,  StopBits.One);
        port.Open();
        port.Write(esc+"@hola mundo!"+ff);
        port.Close();
    }
}

and it works but only with the Epson driver pointing to another port or something else, because if i let it using COM1 the code above throws:

"The given port name does not start with COM/com or does not resolve to a valid serial port."

and for the record, this is not a "port already open" error.

Was it helpful?

Solution

COM1 hold by printer's driver. This prevent opening port by Your application. Try switch printer port in properties of printer's driver to something other then COM1. After this Your application will be free to use COM1.

OTHER TIPS

I think you need to send it to the Driver and not to the port. Check out this article:

http://support.microsoft.com/kb/138594/EN-US/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top