Ver Mensaje Individual
  #2 (permalink)  
Antiguo 12/06/2008, 02:58
fardao
 
Fecha de Ingreso: abril-2007
Mensajes: 85
Antigüedad: 17 años, 1 mes
Puntos: 0
Respuesta: MSComm enviar y recibir datos HEX

¿Alguien me puede echar un cable?

INS de ejemplo a enviar

02 11 05 10 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF

Pondré el código que tengo:

FORM LOAD

msComm.InBufferSize = 1024
msComm.RThreshold = 1
msComm.RTSEnable = True
msComm.Settings = "9600,E,8,2"
msComm.SThreshold = 0
msComm.InputMode = comInputModeText
msComm.InputLen = 1
msComm.CommPort = 1
msComm.PortOpen = True

MSCOMM


For y = 1 To Len(TxEnviar.text)
num = Mid(TxEnviar.text, y, 2)
hex2ascii = hex2ascii & Chr(Val("&h" & num))
y = y + 1
Next y

msComm.Output = hex2ascii

Buffer = msComm.Input

For I = 1 To Len(Buffer)
BufferFinal = BufferFinal & Format(Hex(Asc(Mid(Buffer, I, 1))), "00") & " "
TxRespuesta.Text = BufferFinal
Next