Regístrate gratis para participar de los foros, o si ya estás registrado haz login.
| comentario del autor | Mar May 20, 2008 3:16 pm | |
|
ESTOY HACIENDO UN PROGRAMA EN VISUAL BASIC .NET 2008, Y NECESITO CONECTAR UNA BASCULA MFQ-20 DE LA MARCA TORREY Y LEER LO QUE ESTA PESANDO EN ESE MOMENTO, ENCONTRE ESTE CODIGO EN UN MANUAL DE SOFTWARE DE TORREY PERO NO FUNCIONA Try ConsultaBascula = 0 Using PuertoCom1 As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort("COM1") PuertoCom1.WriteTimeout = 500 PuertoCom1.ReadTimeout = 500 PuertoCom1.WriteLine(Chr(80)) PuertoCom1.WriteLine("p") ConsultaBascula = PuertoCom1.ReadLine PuertoCom1.Close() End Using Catch ex As Exception MsgBox(ex.Message) Finally If ConsultaBascula = 0 Then ConsultaBascula = 1 End Try DE ANTEMANO MUCHAS GRACIAS POR SU AYUDA |
||
| comentario | Mar May 20, 2008 7:16 pm | |
|
Muestra algún mensaje el programa luego ejecutado? Saludos, Sergio. |
||
| comentario del autor | Mar May 20, 2008 7:24 pm | |
|
|
||
| asistió a la solución | Mar May 20, 2008 7:31 pm | |
|
Además podés fijarte si la mini aplicación que funciona tiene algun archivo del tipo .ini o de configuración. Podrías tenes que cambiar la velocidad de sincronización (envio/recepcion de datos) de la interfaz RS, desde el programa. Por lo general conviene comenzar con valores bajos e ir aumentando. Saludos, Sergio. |
||
| comentario | Mie May 21, 2008 10:49 am | |
|
Suerte |
||
| comentario del autor | Mar Jun 03, 2008 11:18 am | |
|
Public Function ConsultaBascula() As Double Dim CadenaRecibida As String = "" Dim CharRecibido As Integer ConsultaBascula = 1 Try Using PuertoCom1 As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort("COM2") PuertoCom1.BaudRate = 9600 PuertoCom1.Parity = IO.Ports.Parity.None PuertoCom1.StopBits = IO.Ports.StopBits.One PuertoCom1.DataBits = 8 PuertoCom1.BreakState = False PuertoCom1.WriteTimeout = 500 PuertoCom1.ReadTimeout = 500 PuertoCom1.WriteLine("P") For I As Int16 = 1 To 7 CharRecibido = PuertoCom1.ReadChar If CharRecibido = 32 Then Else CadenaRecibida = CadenaRecibida & Chr(CharRecibido).ToString() End If Next ConsultaBascula = CDbl(CadenaRecibida) Console.WriteLine("Se logro recuperar: " & ConsultaBascula) PuertoCom1.Close() End Using Catch ex As Exception MsgBox(ex.Message) Finally If ConsultaBascula = 0 Then ConsultaBascula = 1 End Try End Function |
||