📄 regionutil.frm
字号:
End Sub
Private Sub btn_Read_Click()
Dim crc$
Dim byteCount As Integer
Dim strByteCount As String
Dim bytesRead As Integer
Dim numTries As Integer
' Four consecutive Read_Sys commands are sent to the M8.
' Error messages <command fail> and <illegal value> can appear
' in the corresponding text box, but typically the command will pass,
' and the M8 will respond with the value stored in that system parameter.
' The corresponding function will format and display the system parameter value.
flags$ = "20" ' set the CRC_F
If option_Sys.Value = True Then
comand$ = "22" ' this is a Read_Sys command
label_Status.Caption = "Reading from System"
Else
comand$ = "21" ' Assume this is a Read_Mem command
label_Status.Caption = "Reading from Memory"
End If
nbBlks$ = "01"
'******************************************************************************
' FREQUENCY - param 0E
'
' This will read 4 bytes from the M8 and reconstruct something like 915.875
'
'******************************************************************************
strtBlk$ = "0E"
crc$ = Form1.calculateCRC(flags$ & comand$ & strtBlk$ & nbBlks$)
Form1.MSComm1.Output = vbCr & flags$ & comand$ & strtBlk$ & nbBlks$ & crc$ & vbCr
' wait .1 second to give the reader time to process the command before it responds
Start = Timer
Do
Loop Until (Timer - Start) > 0.1
If Form1.GetResponse() = False Then
label_Status.Caption = "Waiting for Command"
textbox_Freq.Text = "<Read Fail>"
Exit Sub
Else
If Mid(Form1.Response$, 2, 2) <> comand$ Then
label_Status.Caption = "Waiting for Command"
textbox_Freq.Text = "<Read Fail>"
Exit Sub
End If
End If
' the read mem (read sys) command passed.
' now format and display the data in the text box
' build the text box
hexByte0$ = Mid$(Form1.Response$, 10, 2)
hexByte1$ = Mid$(Form1.Response$, 8, 2)
hexByte2$ = Mid$(Form1.Response$, 6, 2)
hexByte3$ = Mid$(Form1.Response$, 4, 2)
freqData$ = "&H" & hexByte0$ & hexByte1$ & hexByte2$ & hexByte3$
'Dim abc As Double
abc = CLng(Val(freqData$))
longFreeq$ = Str$(abc)
hex1$ = Mid$(longFreeq$, 2, 3)
hex2$ = Mid$(longFreeq$, 5, 3)
textbox_Freq.Text = hex1$ & "." & hex2$
'******************************************************************************
' MIN FREQUENCY - param 10
'
' This will read 4 bytes from the M8 and reconstruct something like 915.875
'
'******************************************************************************
strtBlk$ = "10"
nbBlks$ = "01"
crc$ = Form1.calculateCRC(flags$ & comand$ & strtBlk$ & nbBlks$)
Form1.MSComm1.Output = vbCr & flags$ & comand$ & strtBlk$ & nbBlks$ & crc$ & vbCr
' wait .1 second to give the reader time to process the command before it responds
Start = Timer
Do
Loop Until (Timer - Start) > 0.1
If Form1.GetResponse() = False Then
label_Status.Caption = "Waiting for Command"
textbox_MinFreq.Text = "<Read Fail>"
Exit Sub
Else
If Mid(Form1.Response$, 2, 2) <> comand$ Then
label_Status.Caption = "Waiting for Command"
textbox_MinFreq.Text = "<Read Fail>"
Exit Sub
End If
End If
' the read mem (read sys) command passed.
' now format and display the data in the text box
' build the text box
hexByte0$ = Mid$(Form1.Response$, 10, 2)
hexByte1$ = Mid$(Form1.Response$, 8, 2)
hexByte2$ = Mid$(Form1.Response$, 6, 2)
hexByte3$ = Mid$(Form1.Response$, 4, 2)
freqData$ = "&H" & hexByte0$ & hexByte1$ & hexByte2$ & hexByte3$
'Dim abc As Double
abc = CLng(Val(freqData$))
longFreeq$ = Str$(abc)
hex1$ = Mid$(longFreeq$, 2, 3)
hex2$ = Mid$(longFreeq$, 5, 3)
textbox_MinFreq.Text = hex1$ & "." & hex2$
'******************************************************************************
' MAX FREQUENCY - param 0F
'
' This will read 4 bytes from the M8 and reconstruct something like 915.875
'
'******************************************************************************
strtBlk$ = "0F"
nbBlks$ = "01"
crc$ = Form1.calculateCRC(flags$ & comand$ & strtBlk$ & nbBlks$)
Form1.MSComm1.Output = vbCr & flags$ & comand$ & strtBlk$ & nbBlks$ & crc$ & vbCr
' wait .1 second to give the reader time to process the command before it responds
Start = Timer
Do
Loop Until (Timer - Start) > 0.1
If Form1.GetResponse() = False Then
label_Status.Caption = "Waiting for Command"
textbox_MaxFreq.Text = "<Read Fail>"
Exit Sub
Else
If Mid(Form1.Response$, 2, 2) <> comand$ Then
label_Status.Caption = "Waiting for Command"
textbox_MaxFreq.Text = "<Read Fail>"
Exit Sub
End If
End If
' the read mem (read sys) command passed.
' now format and display the data in the text box
' build the text box
hexByte0$ = Mid$(Form1.Response$, 10, 2)
hexByte1$ = Mid$(Form1.Response$, 8, 2)
hexByte2$ = Mid$(Form1.Response$, 6, 2)
hexByte3$ = Mid$(Form1.Response$, 4, 2)
freqData$ = "&H" & hexByte0$ & hexByte1$ & hexByte2$ & hexByte3$
'Dim abc As Double
abc = CLng(Val(freqData$))
longFreeq$ = Str$(abc)
hex1$ = Mid$(longFreeq$, 2, 3)
hex2$ = Mid$(longFreeq$, 5, 3)
textbox_MaxFreq.Text = hex1$ & "." & hex2$
'******************************************************************************
' FREQUENCY STEP SIZE - param 11
'
' This will read 2 bytes from the M8 and reconstruct something like 915.875
'
'******************************************************************************
strtBlk$ = "11"
nbBlks$ = "01"
crc$ = Form1.calculateCRC(flags$ & comand$ & strtBlk$ & nbBlks$)
Form1.MSComm1.Output = vbCr & flags$ & comand$ & strtBlk$ & nbBlks$ & crc$ & vbCr
' wait .1 second to give the reader time to process the command before it responds
Start = Timer
Do
Loop Until (Timer - Start) > 0.1
If Form1.GetResponse() = False Then
label_Status.Caption = "Waiting for Command"
textbox_StepSize.Text = "<Read Fail>"
Exit Sub
Else
If Mid(Form1.Response$, 2, 2) <> comand$ Then
label_Status.Caption = "Waiting for Command"
textbox_StepSize.Text = "<Write Fail>"
Exit Sub
End If
End If
' the read mem (read sys) command passed.
' now format and display the data in the text box
' build the text box
If Mid$(Form1.Response$, 4, 2) = "00" Then
textbox_StepSize.Text = "10"
ElseIf Mid$(Form1.Response$, 4, 2) = "01" Then
textbox_StepSize.Text = "25"
ElseIf Mid$(Form1.Response$, 4, 2) = "02" Then
textbox_StepSize.Text = "50"
ElseIf Mid$(Form1.Response$, 4, 2) = "03" Then
textbox_StepSize.Text = "100"
Else
textbox_StepSize.Text = "200"
End If
'******************************************************************************
' POWER - param 16
'******************************************************************************
strtBlk$ = "16"
crc$ = Form1.calculateCRC(flags$ & comand$ & strtBlk$ & nbBlks$)
Form1.MSComm1.Output = vbCr & flags$ & comand$ & strtBlk$ & nbBlks$ & crc$ & vbCr
' wait .1 second to give the reader time to process the command before it responds
Start = Timer
Do
Loop Until (Timer - Start) > 0.2
If Form1.GetResponse() = False Then
label_Status.Caption = "Waiting for Command"
textbox_Pwr.Text = "<Read Fail>"
Exit Sub
Else
If Mid(Form1.Response$, 2, 2) <> comand$ Then
label_Status.Caption = "Waiting for Command"
textbox_Pwr.Text = "<Read Fail>"
Exit Sub
End If
End If
' the read mem (read sys) command passed.
' now format and display the data in the text box
' update the text box for Pwr
retPwrData = Val("&H" & (Mid$(Form1.Response, 4, 2)))
newPwrData = Int(retPwrData)
' Need to convert from Hex to 12-27dBm values
newPwrData = ((CDec(newPwrData) / 10) + 12)
textbox_Pwr.Text = newPwrData
' This will display text for the format 12.1 (limits 12-27dBm)
'******************************************************************************
' MODULATION DEPTH - param addr 17
'******************************************************************************
strtBlk$ = "17"
crc$ = Form1.calculateCRC(flags$ & comand$ & strtBlk$ & nbBlks$)
Form1.MSComm1.Output = vbCr & flags$ & comand$ & strtBlk$ & nbBlks$ & crc$ & vbCr
'' wait .1 second to give the reader time to process the command before it responds
Start = Timer
Do
Loop Until (Timer - Start) > 0.2
If Form1.GetResponse() = False Then
label_Status.Caption = "Waiting for Command"
textbox_ModDepth.Text = "<Read Fail>"
Exit Sub
Else
If Mid(Form1.Response$, 2, 2) <> comand$ Then
label_Status.Caption = "Waiting for Command"
textbox_ModDepth.Text = "<Read Fail>"
Exit Sub
End If
End If
'' the read mem (read sys) command passed.
'' now format and display the data in the text box'
newModVal = Val("&H" & Mid$(Form1.Response, 4, 2))
newModVal = Int(newModVal)
textbox_ModDepth.Text = newModVal
' This will display text in the format 10 (10-100)%
'******************************************************************************
' RISE AND FALL TIMES
'******************************************************************************
' not yet supported
label_Status.Caption = "Waiting For Command"
End Sub
Private Function setStatus(inputString)
label_Status.Caption = inputString
DoEvents
Start = Timer
Do
Loop Until (Timer - Start) > 0.5
End Function
'Menu Item functions from here down
Private Sub mnuFile_Exit_Click()
If (Form1.MSComm1.PortOpen = True) Then
Form1.MSComm1.PortOpen = False
End If
nextForm = 0 ' so the the function Private Sub Form_Unload(Cancel As Integer) does not load a new form
Unload Form1
End Sub
Private Sub USA_Click()
textbox_Freq.Text = "915.000"
textbox_MaxFreq.Text = "928.000"
textbox_MinFreq.Text = "902.000"
textbox_StepSize.Text = "200"
textbox_Pwr.Text = "12"
textbox_ModDepth.Text = "100"
textbox_RiseTime.Text = "300"
End Sub
Private Sub Europe_Click()
textbox_Freq.Text = "869.525"
textbox_MaxFreq.Text = "868.000"
textbox_MinFreq.Text = "870.000"
textbox_StepSize.Text = "25"
textbox_Pwr.Text = "12"
textbox_ModDepth.Text = "100"
textbox_RiseTime.Text = "300"
End Sub
Private Sub Japan_Click()
textbox_Freq.Text = "953.000"
textbox_MaxFreq.Text = "950.000"
textbox_MinFreq.Text = "956.000"
textbox_StepSize.Text = "25"
textbox_Pwr.Text = "12"
textbox_ModDepth.Text = "100"
textbox_RiseTime.Text = "300"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -