从外部设备接收数据 [英] Receiving data from external device

查看:86
本文介绍了从外部设备接收数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个外部设备,其中代码已经以十六进制格式加载,并通过rs232通过rs232我必须下载数据作为我的笔记本电脑中的新文件帮助我如何做到这一点



例如:外部设备中的十六进制代码是

:108000000000000300000000000603000304030456



i必须下载这个格式化使用vb6编码到我的笔记本电脑



谢谢



我尝试过:



 选项 明确 
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset

私有 Sub configure_Click()

Form2.Show

结束 Sub

' Sub rs232()
' Dim temp_varc,serialen,keyvolume
' if(temp_varc = 0x38)then
' serialen = 1
' 上传
' serialen = 0
' keyvolume(5000)
' 结束如果
' End Sub
Privat e Sub upload_Click()

Dim ff,i < span class =code-keyword> As Integer
Dim temp_varc, serialen,keyvolume
Dim 地址,buf,strtbyte 作为 字符串
' buf =空格(50)

如果 MSComm1.PortOpen = True 然后
使用 CommonDialog1
.InitDir = App.Path
.FileName =
.Filter = Hex文件(* .hex)| * .hex
。显示保存

ff = FreeFile
打开.FileName 用于输出锁定读取 As #ff
' Form1.Label3.Caption =输入循环和等待命令

地址= 8000
打印#ff,( 1
' gets(buf,空格(50))

(地址< 8090
打印#ff,( 2:10& address& 00
< span class =code-comment>' sendblock(address)
address = address + Hex $( 16
Wend

address = 8000
(地址< 8090
打印#ff, ( 3:10& address& 00
' sendblock(地址)
地址=地址+十六进制$( 16
Wend

打印#ff,( 3:00000001FF
打印#ff,( 4

关闭#ff

< span class =code-keyword>结束 使用
结束 如果

结束 Sub

解决方案

16
Wend

address = 8000
(地址< 8090
打印#ff,( 3:10& address& 00
< span class =code-comment>' sendblock(address)
address = address + Hex


< blockquote>( 16
Wend

打印#ff, ( 3:00000001FF
打印#ff,( 4

关闭#ff

结束 使用
结束 如果

En d Sub


您的代码段不包含串口的任何读数。



我建议阅读 MSComm控件(MSComm控件) [ ^ ]。一个简单的例子可以在 MSComm控件示例(MSComm控件) [ ^ ]。

we are having an external device in which already the code was loaded in hex format and through vb6 via rs232 i have to download the data as a new file in my laptop help me how to do this

eg: the hex code present in the external device was
:108000000000000300000000000603000304030456

i have to download this format using vb6 coding to my laptop

thank you

What I have tried:

Option Explicit
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset

Private Sub configure_Click()

    Form2.Show

End Sub

'Sub rs232()
    'Dim temp_varc, serialen, keyvolume
    'if (temp_varc=0x38) then
        'serialen = 1
        'upload
        'serialen = 0
        'keyvolume (5000)
    'End If
'End Sub
Private Sub upload_Click()

    Dim ff, i As Integer
    Dim temp_varc, serialen, keyvolume
    Dim address, buf, strtbyte As String
    'buf = Space(50)

     If MSComm1.PortOpen = True Then
        With CommonDialog1
        .InitDir = App.Path
        .FileName = ""
        .Filter = "Hex File (*.hex)|*.hex"
        .ShowSave

        ff = FreeFile
        Open .FileName For Output Lock Read As #ff
            'Form1.Label3.Caption = "Entering While Loop and Waiting For Command"

            address = 8000
            Print #ff, ("1 ")
            'gets(buf, Space(50))

            While (address < 8090)
                Print #ff, ("2 :10" & address & "00")
                'sendblock (address)
                address = address + Hex$(16)
            Wend
            
            address = 8000
            While (address < 8090)
                Print #ff, ("3 :10" & address & "00")
                'sendblock (address)
                address = address + Hex$(16)
            Wend
            
            Print #ff, ("3 :00000001FF")
            Print #ff, ("4 ")
 
        Close #ff
        
    End With
    End If
 
End Sub

解决方案

(16) Wend address = 8000 While (address < 8090) Print #ff, ("3 :10" & address & "00") 'sendblock (address) address = address + Hex


(16) Wend Print #ff, ("3 :00000001FF") Print #ff, ("4 ") Close #ff End With End If End Sub


Your code snippet does not include any reading from the serial port.

I suggest to read about MSComm Control (MSComm Control)[^]. A simple example can be found at MSComm Control Example (MSComm Control)[^].


这篇关于从外部设备接收数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆