-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathSERIAL_PORT_RIBBON.bas
122 lines (68 loc) · 3.64 KB
/
SERIAL_PORT_RIBBON.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
Attribute VB_Name = "SERIAL_PORT_RIBBON"
Option Explicit
'----------------------------------------
' Change Com port number here if required
'
Const Port_Number As Long = 1
'----------------------------------------
Dim Stop_Result As Boolean
Dim Start_Result As Boolean
Dim Signal_Result As Boolean
Dim Characters_Sent As Long
Dim Characters_Waiting As Long
Dim Send_Message As String
Dim Port_Settings As String
Dim Characters_Read As String
Dim Message_Box_Text As String
Dim Message_Box_Title As String
Dim Message_Box_Result As Long
Const Message_Box_Buttons As Long = vbInformation + vbOKOnly
'
Sub COM_PORT_CONTROL_1(Optional control As Variant) 'Callback for COM_PORT_START onAction
Message_Box_Title = "Start COM Port " & Port_Number
Start_Result = START_COM_PORT(Port_Number)
Port_Settings = "Port Settings = " & GET_PORT_SETTINGS(Port_Number) & vbCrLf & vbCrLf
Message_Box_Text = Port_Settings & "Start Result = " & Start_Result
Message_Box_Result = MsgBox(Message_Box_Text, Message_Box_Buttons, Message_Box_Title)
End Sub
Sub COM_PORT_CONTROL_2(Optional control As Variant) 'Callback for COM_PORT_STOP onAction
Message_Box_Title = "Stop COM Port " & Port_Number
Stop_Result = STOP_COM_PORT(Port_Number)
Message_Box_Text = "Stop Result = " & Stop_Result
Message_Box_Result = MsgBox(Message_Box_Text, Message_Box_Buttons, Message_Box_Title)
End Sub
Sub COM_PORT_DATA_1(Optional control As Variant) 'Callback for COM_PORT_CHECK onAction
Message_Box_Title = "Check for data waiting"
Port_Settings = "Port Settings = " & GET_PORT_SETTINGS(Port_Number) & vbCrLf & vbCrLf
Characters_Waiting = CHECK_COM_PORT(Port_Number)
Message_Box_Text = Port_Settings & "Characters Waiting = " & Characters_Waiting
Message_Box_Result = MsgBox(Message_Box_Text, Message_Box_Buttons, Message_Box_Title)
End Sub
Sub COM_PORT_DATA_2(Optional control As Variant) 'Callback for COM_PORT_READ onAction
Message_Box_Title = "COM Port Data Read Test"
Port_Settings = "Port Settings = " & GET_PORT_SETTINGS(Port_Number) & vbCrLf & vbCrLf
Characters_Read = READ_COM_PORT(Port_Number, 20)
Message_Box_Text = Port_Settings & "Characters Read = " & Characters_Read
Message_Box_Result = MsgBox(Message_Box_Text, Message_Box_Buttons, Message_Box_Title)
End Sub
Sub COM_PORT_DATA_3(Optional control As Variant) 'Callback for COM_PORT_WRITE onAction
Message_Box_Title = "COM Port Data Send Test"
Port_Settings = "Port Settings = " & GET_PORT_SETTINGS(Port_Number) & vbCrLf & vbCrLf
Send_Message = Application.Name & " " & Application.Version & " @ " & Time & vbCrLf
Characters_Sent = Len(Send_Message)
SEND_COM_PORT Port_Number, Send_Message
Message_Box_Text = Port_Settings & "Characters Sent = " & Characters_Sent
Message_Box_Result = MsgBox(Message_Box_Text, Message_Box_Buttons, Message_Box_Title)
End Sub
Sub COM_PORT_SIGNAL_1(Optional control As Variant) 'Callback for COM_PORT_RTS_ON onAction
Message_Box_Title = "COM Port " & Port_Number & " - Request To Send ON"
Signal_Result = REQUEST_TO_SEND(Port_Number, 1)
Message_Box_Text = Port_Settings & "Set RTS Result = " & Signal_Result
Message_Box_Result = MsgBox(Message_Box_Text, Message_Box_Buttons, Message_Box_Title)
End Sub
Sub COM_PORT_SIGNAL_2(Optional control As Variant) 'Callback for COM_PORT_RTS_OFF onAction
Message_Box_Title = "COM Port " & Port_Number & " - Request To Send OFF"
Signal_Result = REQUEST_TO_SEND(Port_Number, 0)
Message_Box_Text = Port_Settings & "Set RTS Result = " & Signal_Result
Message_Box_Result = MsgBox(Message_Box_Text, Message_Box_Buttons, Message_Box_Title)
End Sub