necesito que desde mi aplicación de gestión se pueda abrir un cajón
monedero (como los de los TPVs) que va conectado al PC por el puerto
serie. ¿Alguien sabe qué código habría que enviar y cómo?
Gracias.
Yo tengo una clase que conseguí por internet para mandar y recibir datos al
puerto serie.Googlea rs232 .net y puede que así la encuentres. Si no la
encuentras, puedes mandarme un mail con tu dirección de correo y te la envio
porque es algo grande para postearla akí.
Por cierto ten en cuenta que para poder abrir un cajon del monedero, supongo
vamos, que debes mirar en la documentación del mismo que caracteres le debes
mandar para ejecutar la acción, la paridad y todo eso para establecer
correctamente la comunicación.
Espero que te sirva de algo
Salu2
"Lope" <aslkdjf...@sldkjfgsd.com> escribió en el mensaje
news:4mvc60F...@individual.net...
"Lope" <aslkdjf...@sldkjfgsd.com> escribió en el mensaje
news:4mvc60F...@individual.net...
Public Const GENERIC_WRITE = &H40000000
Public Const OPEN_EXISTING = 3
Public Const FILE_SHARE_WRITE = &H2
Public Structure SECURITY_ATTRIBUTES
Private nLength As Integer
Private lpSecurityDescriptor As Integer
Private bInheritHandle As Integer
End Structure
Dim SA As SECURITY_ATTRIBUTES
Dim outFile As FileStream
Dim Safe As Microsoft.Win32.SafeHandles.SafeFileHandle
Dim LPTPORT As String
Dim hPort As Integer
Dim hPortP As IntPtr
Dim retval As Integer
Pubic Declare Function CreateFile Lib "kernel32" Alias "CreateFileA"
(ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal
dwShareMode As Integer, ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES,
ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes As
Integer, ByVal hTemplateFile As Integer) As Integer
Public Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle"
(ByVal hObject As Integer) As Integer
Public Sub AbrirCajon()
Dim fw As StreamWriter
LPTPORT = "LPT1" 'El puerto que sea.
hPort = CreateFile(LPTPORT, GENERIC_WRITE, FILE_SHARE_WRITE, SA,
OPEN_EXISTING, 0, 0)
hPortP = New IntPtr(hPort) 'Convierte Integer to IntPtr
Safe = New Microsoft.Win32.SafeHandles.SafeFileHandle(hPortP, True)
If Not Safe.IsInvalid Then
outFile = New System.IO.FileStream(Safe, IO.FileAccess.Write)
fw = New System.IO.StreamWriter(outFile)
fw.AutoFlush = True
fw.WriteLine(Chr(27) & Chr(112) & 0) 'Genérico Epson
fw.Close()
End If
CloseHandle(hPort)
End Sub