Question Serial Ports

Danerd100

Member
Joined
Aug 31, 2008
Messages
8
Programming Experience
1-3
Hi, My first post on the forum

Well, I have been programming for about 1.5 years now. I am trying to make a basic POS program. To do that, I need to interact with a Receipt Printer and a Cash Drawer. The Receipt printer is an EPSON TM-T88iii.

In my program, I have SerialPort1 setup. It is plugged into COM1, so I set the SerialPort1.PortName to COM1

When I run the program on a computer without the printer attached, I get no error message. When I run a program with the Printer attached, i get a message saying
"The port selected is not a COM/com port, or does not resolve to a valid serial port.
Parameter name: portName"

details

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentException: The given port name does not start with COM/com or does not resolve to a valid serial port.
Parameter name: portName
at System.IO.Ports.SerialStream..ctor(String portName, Int32 baudRate, Parity parity, Int32 dataBits, StopBits stopBits, Int32 readTimeout, Int32 writeTimeout, Handshake handshake, Boolean dtrEnable, Boolean rtsEnable, Boolean discardNull, Byte parityReplace)
at System.IO.Ports.SerialPort.Open()
at WindowsApplication1.Module1.Print_Receipt()
at WindowsApplication1.Form1.Button3_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
WindowsApplication1
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Documents%20and%20Settings/Dan/Local%20Settings/Apps/2.0/TWRHG5H0.TZX/O50N8M7H.JTR/wind..tion_82c602ef61cf742f_0001.0000_74ab06c808ed7d42/WindowsApplication1.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.


Also, if i make a non-existent printer on the comp without one, and put it on com1, i get the same error message
 
Last edited by a moderator:
Hello.

You can check if the port is correctly recognized by using the array from My.Computer.Ports.SerialPortNames . Also it could be that the port is blocked by somekind of driver software, I'd check that.

Bobby
 
Danerd100

You should really check out Pos for .Net from microsoft.

It takes away a lot of the headache of interacting with POS peripherals.
 
How do I check to see if it can be blocked by drivers?

Could the fact that it sees it as in use by another device because a driver came with it cause that?
 
Last edited:
Does anyone have the TM-T88III? That has experience with programming with it?

EDIT:

Okay, it works. My problem was that I have to change the port that the driver selects to a different one. The driver of the printer made it so that port wasn't in use. So this works either without the driver installed, or if it is just not in the correct spot
 
Last edited:
Back
Top