| | |
send binary file to serial port
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2009
Posts: 39
Reputation:
Solved Threads: 0
Hey folks,
I have an Epson POS printer which support printing via my COM port using ESC/POS. This all works well in my c# app. I have used Epson's BMP converter tool to convert a bmp file to a binary file which can be sent directly to the printer.
How would I get my c# app to send this binary file straight to COM1?
I am familiar with the basic sp.Write("lalala") and sp.Writeline("lalala") commands.
The binary file is only 4kb in size so do I really need a binarystreamer? Can I not just do something like fopen(logo.dat,br) ??
Your help is appreciated thanks
I have an Epson POS printer which support printing via my COM port using ESC/POS. This all works well in my c# app. I have used Epson's BMP converter tool to convert a bmp file to a binary file which can be sent directly to the printer.
How would I get my c# app to send this binary file straight to COM1?
I am familiar with the basic sp.Write("lalala") and sp.Writeline("lalala") commands.
The binary file is only 4kb in size so do I really need a binarystreamer? Can I not just do something like fopen(logo.dat,br) ??
Your help is appreciated thanks
Last edited by jonnytabpni; May 17th, 2009 at 8:36 pm.
•
•
Join Date: May 2009
Posts: 39
Reputation:
Solved Threads: 0
Hi guys,
No, this printer doesn't have on-board memory. Its the TM-T88ii (One mark below the version which does have memory).
I don't think I can put the BMP into a byte array as this "binary file" is in special Epson ESC/POS code so need to be sent.
Now, could i put the binary file into a byte array?
Cheers
No, this printer doesn't have on-board memory. Its the TM-T88ii (One mark below the version which does have memory).
I don't think I can put the BMP into a byte array as this "binary file" is in special Epson ESC/POS code so need to be sent.
Now, could i put the binary file into a byte array?
Cheers
•
•
Join Date: May 2009
Posts: 39
Reputation:
Solved Threads: 0
this looks like it could do the job for me:
http://kseesharp.blogspot.com/2007/1...yte-array.html
I would have to put the number of byte of the file into the serielpor's Write method though
http://kseesharp.blogspot.com/2007/1...yte-array.html
I would have to put the number of byte of the file into the serielpor's Write method though
•
•
Join Date: Apr 2009
Posts: 7
Reputation:
Solved Threads: 2
Maybe you can send the image data to the printer using the above but I don't know if the desired result can be achieved.. i.e positioning of the image etc..
I have never worked with the TM88II just the TM88III upwards.
Is there no option to get rid of the TM88II as its about 7 years old now and replace it with a nice new TM88III that can handle images nicely
I have never worked with the TM88II just the TM88III upwards.
Is there no option to get rid of the TM88II as its about 7 years old now and replace it with a nice new TM88III that can handle images nicely
•
•
Join Date: Oct 2009
Posts: 1
Reputation:
Solved Threads: 0
0
#8 Oct 9th, 2009
Please, I need some example about sending a bitmap to a printer without using OPOS. I connect the printer via an USB/Pararel converter and I have to use Generic / Text Only driver because the driver only lets me assign USB, LPT or COM ports.
I think that I can only use ESC/POS commands to send it.
I think that I can only use ESC/POS commands to send it.
•
•
•
•
Maybe you can send the image data to the printer using the above but I don't know if the desired result can be achieved.. i.e positioning of the image etc..
I have never worked with the TM88II just the TM88III upwards.
Is there no option to get rid of the TM88II as its about 7 years old now and replace it with a nice new TM88III that can handle images nicely
0
#9 Oct 9th, 2009
You can create a named pipe for LPT1 or which ever port the printer is on and send it data:
C# Syntax (Toggle Plain Text)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.IO; using System.Management; using System.Net; using System.Reflection; using System.Runtime.InteropServices; using System.Windows.Forms; using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo.RegisteredServers; using Microsoft.Win32; using Microsoft.Win32.SafeHandles; [DllImport("kernel32.dll", SetLastError = true)] public static extern SafeFileHandle CreateNamedPipe( String pipeName, uint dwOpenMode, uint dwPipeMode, uint nMaxInstances, uint nOutBufferSize, uint nInBufferSize, uint nDefaultTimeOut, IntPtr lpSecurityAttributes); /* -------------------------------------------------------------------- */ [DllImport("kernel32.dll", SetLastError = true)] public static extern int ConnectNamedPipe( SafeFileHandle hNamedPipe, IntPtr lpOverlapped); /* -------------------------------------------------------------------- */ [DllImport("kernel32.dll", SetLastError = true)] public static extern SafeFileHandle CreateFile( String pipeName, uint dwDesiredAccess, uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplate); //Inside a method: try { uint GENERIC_READ = (0x80000000); uint GENERIC_WRITE = (0x40000000); uint OPEN_EXISTING = 3; uint FILE_FLAG_OVERLAPPED = (0x40000000); SafeFileHandle pipeHandle = CreateFile( "LPT1", GENERIC_READ | GENERIC_WRITE, 0, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero); //could not get a handle to the named pipe if (pipeHandle.IsInvalid) return; using (FileStream fStream = new FileStream(pipeHandle, FileAccess.Write)) { char cOp = Convert.ToChar(7); byte bOp = Convert.ToByte(cOp); fStream.WriteByte(bOp); fStream.Flush(); fStream.Close(); } } catch { }
![]() |
Similar Threads
- Send data on a serial port (C)
- Send data on a serial port (C++)
- How do I send a 5 volts signal to my serial port (Visual Basic 4 / 5 / 6)
- Serial port communication using C++ (C++)
- need help convert c++ to vb6 serial port (Visual Basic 4 / 5 / 6)
- iam having doubt in serial port (C)
- send raw data via serial (Python)
Other Threads in the C# Forum
- Previous Thread: C# Generate Fixtures
- Next Thread: Mouse Hook Help...
| Thread Tools | Search this Thread |
.net 7 access algorithm app application array barchart bitmap box broadcast c# cast check checkbox client color combo combobox concurrency control conversion csharp custom data database datagrid datagridview dataset datatable datetime degrees development draganddrop drawing enabled encryption enum event excel file form format forms function gdi+ getoutlookcontactusinfcsvfile globalization httpwebrequest image index input install java label list listbox localization mandelbrot math microsoftc#visualexpress mono mouseclick mysql operator path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox server sleep socket sql sql-server statistics stream string table text textbox thread time timer update usercontrol validate validation visualstudio webbrowser windows winforms wpf xml






