⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mducomm.bas

📁 VB平台单片机与PC机串口通信的PC端程序。小巧易用
💻 BAS
字号:
Attribute VB_Name = "mduComm"
Option Explicit

'自动应答实现连接,连接后进入数据交换状态
'等待主叫方发送g_GIVE_ME_DATA 命令
'超时则断开连接并复位端口
'终端以二进制形式接收服务器发来的所要数据命令

'Timer延时要改************

Public g_bCOMMSETOK As Boolean

Public Const g_WAIT = 30
Public Const g_SENDDATALENGTH = 768  '发送二进制文件内容块大小

'接收服务器所要数据标识
Public Const g_GIVE_ME_DATA = "@G@"  '给我数据
Public Const g_GIVE_ME_REC = "@R@"   '给我记录
Public Const g_GIVE_ME_FILE = "@F@"  '给我文件
Public Const g_I_GET_IT = "@I@"      '我得到了(一条记录)
Public Const g_I_GET_ALL_REC = "@A@" '服务器收到所有记录后发回的信息
Public Const g_CHAREND = "&*@"       '发给服务器的文本信息结尾符

'视频信息显示常量
Public Const g_SCREEN_L = 5
Public Const g_SCREEN_T = 30
Public Const g_SCREEN_W = 498
Public Const g_SCREEN_H = 288
Public Const g_PW = 768
Public Const g_PH = 576

Public Sub SetRegister(Comm As Control, Reg%, Val%)
    Comm.Output = "ATS" + Str(Reg%) + "=" + Str(Val%) & vbCrLf
End Sub

Public Sub GetRegister(Comm As Control, Reg$)
    Comm.Output = "ATS" + Reg$ + "?" & vbCrLf
End Sub

Public Sub Answer(Comm As Control)
    Comm.Output = "ATA" & vbCrLf
End Sub

Public Sub HalfDuplex(Comm As Control)
    Comm.Output = "ATF0" & vbCrLf
End Sub

Public Sub FullDuplex(Comm As Control)
    Comm.Output = "ATF1" & vbCrLf
End Sub

Public Sub RcInteger(Comm As Control)
        Comm.Output = "ATV0" & vbCrLf
End Sub

Public Sub RcAlpha(Comm As Control)
        Comm.Output = "ATV1" & vbCrLf
End Sub

Public Sub ResultCodesOn(Comm As Control)
    Comm.Output = "ATQ0" & vbCrLf
End Sub

Public Sub ResultCodesOff(Comm As Control)
    Comm.Output = "ATQ1" & vbCrLf
End Sub

Public Sub ProductID(Comm As Control)
    Comm.Output = "ATI0" & vbCrLf
End Sub

Public Sub EchoOn(Comm As Control)
    Comm.Output = "ATE1" & vbCrLf
End Sub

Public Sub EchoOff(Comm As Control)
    Comm.Output = "ATE0" & vbCrLf
End Sub

Public Sub CarrierOn(Comm As Control)
    Comm.Output = "ATC1" & vbCrLf
End Sub

Public Sub CarrierOff(Comm As Control)
    Comm.Output = "ATC0" & vbCrLf
End Sub

Public Sub AnswerAuto(Comm As Control)
    Comm.Output = "ATs0=1" & vbCrLf
End Sub

Public Sub AnswerModeP(Comm As Control, DialStr$)
    Comm.Output = "ATDP " + DialStr$ + "R" & vbCrLf
End Sub

Public Sub AnswerModeT(Comm As Control, DialStr$)
    Comm.Output = "ATDT " + DialStr$ + "R" & vbCrLf
End Sub

Public Sub Attention(Comm As Control, ATStr$)
    Comm.Output = "AT" + ATStr$ & vbCrLf
End Sub

Public Sub ROMChecksum(Comm As Control)
    Comm.Output = "ATI1" & vbCrLf
End Sub

Public Sub CsReturnCode(Comm As Control)
    Comm.Output = "ATI3" & vbCrLf
End Sub

Public Sub SpeakerOn(Comm As Control)
    Comm.Output = "ATM1" & vbCrLf
End Sub

Public Sub SpeakerAlwaysOn(Comm As Control)
    Comm.Output = "ATM2" & vbCrLf
End Sub

Public Sub SpeakerOff(Comm As Control)
    Comm.Output = "ATM0" & vbCrLf
End Sub

Public Sub DialTouch(Comm As Control, DialStr$)
    Comm.Output = "ATDT " + DialStr$ & vbCrLf
End Sub

Public Sub DialPulse(Comm As Control, DialStr$)
    Comm.Output = "ATDP " + DialStr$ & vbCrLf
End Sub

Public Sub OffHook(Comm As Control)
    Comm.Output = "ATH0" & vbCrLf
End Sub

Public Sub OffHookReset(Comm As Control)
    Comm.Output = "ATO1" & vbCrLf
End Sub

Public Sub OnHook(Comm As Control)
    Comm.Output = "ATH1" & vbCrLf
End Sub

Public Sub OffHookSame(Comm As Control)
    Comm.Output = "ATO0" & vbCrLf
End Sub

Public Sub RepeatCommand(Comm As Control)
    Comm.Output = "A/" & vbCrLf
End Sub

Public Sub Reset(Comm As Control)
    Comm.Output = "ATZ" & vbCrLf   'Reset modem
End Sub

Public Sub Volume(Comm As Control, Vol As Integer)
    Select Case Vol
        Case 0
            Comm.Output = "ATL0" & vbCrLf
        Case 1
            Comm.Output = "ATL1" & vbCrLf
        Case 2
            Comm.Output = "ATL2" & vbCrLf
        Case 3
            Comm.Output = "ATL3" & vbCrLf
        Case Else
            MsgBox "Invalid speaker volume!"
    End Select
End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -