📄 form1.vb
字号:
Me.GroupCANSetup.Controls.Add(Me.BnDriverStatus)
Me.GroupCANSetup.Controls.Add(Me.BnActivateChannels)
Me.GroupCANSetup.Controls.Add(Me.CBoxHardwareType)
Me.GroupCANSetup.Location = New System.Drawing.Point(8, 0)
Me.GroupCANSetup.Name = "GroupCANSetup"
Me.GroupCANSetup.Size = New System.Drawing.Size(328, 96)
Me.GroupCANSetup.TabIndex = 4
Me.GroupCANSetup.TabStop = False
Me.GroupCANSetup.Text = "CAN Setup"
'
'BnGetDriverConfig
'
Me.BnGetDriverConfig.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.BnGetDriverConfig.Location = New System.Drawing.Point(224, 64)
Me.BnGetDriverConfig.Name = "BnGetDriverConfig"
Me.BnGetDriverConfig.Size = New System.Drawing.Size(96, 23)
Me.BnGetDriverConfig.TabIndex = 14
Me.BnGetDriverConfig.Text = "GetDriverConfig"
'
'CBoxBitrate
'
Me.CBoxBitrate.Items.AddRange(New Object() {"33333", "100000", "500000", "1000000"})
Me.CBoxBitrate.Location = New System.Drawing.Point(8, 48)
Me.CBoxBitrate.Name = "CBoxBitrate"
Me.CBoxBitrate.Size = New System.Drawing.Size(200, 21)
Me.CBoxBitrate.TabIndex = 13
Me.CBoxBitrate.Text = "33333"
'
'BnDriverStatus
'
Me.BnDriverStatus.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.BnDriverStatus.Location = New System.Drawing.Point(224, 16)
Me.BnDriverStatus.Name = "BnDriverStatus"
Me.BnDriverStatus.Size = New System.Drawing.Size(96, 23)
Me.BnDriverStatus.TabIndex = 12
Me.BnDriverStatus.Text = "ClosePort"
'
'BnActivateChannels
'
Me.BnActivateChannels.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.BnActivateChannels.Location = New System.Drawing.Point(224, 40)
Me.BnActivateChannels.Name = "BnActivateChannels"
Me.BnActivateChannels.Size = New System.Drawing.Size(96, 23)
Me.BnActivateChannels.TabIndex = 11
Me.BnActivateChannels.Text = "Activate"
'
'CBoxHardwareType
'
Me.CBoxHardwareType.Location = New System.Drawing.Point(8, 24)
Me.CBoxHardwareType.Name = "CBoxHardwareType"
Me.CBoxHardwareType.Size = New System.Drawing.Size(200, 21)
Me.CBoxHardwareType.TabIndex = 0
Me.CBoxHardwareType.Text = "No Hardware found"
'
'BnCanAck
'
Me.BnCanAck.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.BnCanAck.Location = New System.Drawing.Point(112, 16)
Me.BnCanAck.Name = "BnCanAck"
Me.BnCanAck.Size = New System.Drawing.Size(96, 24)
Me.BnCanAck.TabIndex = 13
Me.BnCanAck.Text = "ACK:on"
'
'BnTxReceipt
'
Me.BnTxReceipt.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.BnTxReceipt.Location = New System.Drawing.Point(8, 16)
Me.BnTxReceipt.Name = "BnTxReceipt"
Me.BnTxReceipt.Size = New System.Drawing.Size(96, 23)
Me.BnTxReceipt.TabIndex = 8
Me.BnTxReceipt.Text = "Tx:on TxRq:off"
'
'Bn_ResetClock
'
Me.Bn_ResetClock.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Bn_ResetClock.Location = New System.Drawing.Point(112, 8)
Me.Bn_ResetClock.Name = "Bn_ResetClock"
Me.Bn_ResetClock.Size = New System.Drawing.Size(96, 24)
Me.Bn_ResetClock.TabIndex = 7
Me.Bn_ResetClock.Text = "ResetClock"
'
'BnClear
'
Me.BnClear.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.BnClear.Location = New System.Drawing.Point(112, 16)
Me.BnClear.Name = "BnClear"
Me.BnClear.Size = New System.Drawing.Size(96, 23)
Me.BnClear.TabIndex = 5
Me.BnClear.Text = "Clear"
'
'GroupBox3
'
Me.GroupBox3.Controls.Add(Me.BnShowVecHardwControl)
Me.GroupBox3.Controls.Add(Me.BnCloseApp)
Me.GroupBox3.Controls.Add(Me.BnClear)
Me.GroupBox3.Location = New System.Drawing.Point(8, 360)
Me.GroupBox3.Name = "GroupBox3"
Me.GroupBox3.Size = New System.Drawing.Size(328, 48)
Me.GroupBox3.TabIndex = 6
Me.GroupBox3.TabStop = False
'
'BnShowVecHardwControl
'
Me.BnShowVecHardwControl.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.BnShowVecHardwControl.Location = New System.Drawing.Point(216, 16)
Me.BnShowVecHardwControl.Name = "BnShowVecHardwControl"
Me.BnShowVecHardwControl.Size = New System.Drawing.Size(104, 24)
Me.BnShowVecHardwControl.TabIndex = 6
Me.BnShowVecHardwControl.Text = "Vector Hardware"
'
'GroupAcceptance
'
Me.GroupAcceptance.Controls.Add(Me.BnCanAcceptReset)
Me.GroupAcceptance.Controls.Add(Me.Label4)
Me.GroupAcceptance.Controls.Add(Me.TBoxCanAcceptTo)
Me.GroupAcceptance.Controls.Add(Me.Label3)
Me.GroupAcceptance.Controls.Add(Me.TBoxCanAcceptFrom)
Me.GroupAcceptance.Controls.Add(Me.BnResetAccepFilter)
Me.GroupAcceptance.Location = New System.Drawing.Point(8, 96)
Me.GroupAcceptance.Name = "GroupAcceptance"
Me.GroupAcceptance.Size = New System.Drawing.Size(328, 56)
Me.GroupAcceptance.TabIndex = 7
Me.GroupAcceptance.TabStop = False
Me.GroupAcceptance.Text = "Acceptance"
'
'BnCanAcceptReset
'
Me.BnCanAcceptReset.Location = New System.Drawing.Point(248, 24)
Me.BnCanAcceptReset.Name = "BnCanAcceptReset"
Me.BnCanAcceptReset.Size = New System.Drawing.Size(64, 23)
Me.BnCanAcceptReset.TabIndex = 17
Me.BnCanAcceptReset.Text = "Reset"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(80, 32)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(24, 16)
Me.Label4.TabIndex = 16
Me.Label4.Text = "To"
'
'TBoxCanAcceptTo
'
Me.TBoxCanAcceptTo.Location = New System.Drawing.Point(112, 24)
Me.TBoxCanAcceptTo.Name = "TBoxCanAcceptTo"
Me.TBoxCanAcceptTo.RightToLeft = System.Windows.Forms.RightToLeft.Yes
Me.TBoxCanAcceptTo.Size = New System.Drawing.Size(40, 20)
Me.TBoxCanAcceptTo.TabIndex = 15
Me.TBoxCanAcceptTo.Text = "100"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(8, 32)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(32, 16)
Me.Label3.TabIndex = 14
Me.Label3.Text = "From"
'
'TBoxCanAcceptFrom
'
Me.TBoxCanAcceptFrom.Location = New System.Drawing.Point(40, 24)
Me.TBoxCanAcceptFrom.Name = "TBoxCanAcceptFrom"
Me.TBoxCanAcceptFrom.RightToLeft = System.Windows.Forms.RightToLeft.Yes
Me.TBoxCanAcceptFrom.Size = New System.Drawing.Size(40, 20)
Me.TBoxCanAcceptFrom.TabIndex = 13
Me.TBoxCanAcceptFrom.Text = "5"
'
'BnResetAccepFilter
'
Me.BnResetAccepFilter.Location = New System.Drawing.Point(184, 24)
Me.BnResetAccepFilter.Name = "BnResetAccepFilter"
Me.BnResetAccepFilter.Size = New System.Drawing.Size(64, 23)
Me.BnResetAccepFilter.TabIndex = 12
Me.BnResetAccepFilter.Text = "Set"
'
'BnFlushTXQueue
'
Me.BnFlushTXQueue.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.BnFlushTXQueue.Location = New System.Drawing.Point(8, 8)
Me.BnFlushTXQueue.Name = "BnFlushTXQueue"
Me.BnFlushTXQueue.Size = New System.Drawing.Size(96, 24)
Me.BnFlushTXQueue.TabIndex = 9
Me.BnFlushTXQueue.Text = "FlushTXQueue"
'
'BnFlushRXQueue
'
Me.BnFlushRXQueue.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.BnFlushRXQueue.Location = New System.Drawing.Point(8, 32)
Me.BnFlushRXQueue.Name = "BnFlushRXQueue"
Me.BnFlushRXQueue.Size = New System.Drawing.Size(96, 24)
Me.BnFlushRXQueue.TabIndex = 10
Me.BnFlushRXQueue.Text = "FlushRXQueue"
'
'BnRXQueueLevel
'
Me.BnRXQueueLevel.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.BnRXQueueLevel.Location = New System.Drawing.Point(112, 32)
Me.BnRXQueueLevel.Name = "BnRXQueueLevel"
Me.BnRXQueueLevel.Size = New System.Drawing.Size(96, 24)
Me.BnRXQueueLevel.TabIndex = 11
Me.BnRXQueueLevel.Text = "RXQueueLevel"
'
'BnChipstate
'
Me.BnChipstate.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.BnChipstate.Location = New System.Drawing.Point(216, 8)
Me.BnChipstate.Name = "BnChipstate"
Me.BnChipstate.Size = New System.Drawing.Size(96, 24)
Me.BnChipstate.TabIndex = 12
Me.BnChipstate.Text = "Chipstate"
'
'BnGetSyncTime
'
Me.BnGetSyncTime.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.BnGetSyncTime.Location = New System.Drawing.Point(216, 32)
Me.BnGetSyncTime.Name = "BnGetSyncTime"
Me.BnGetSyncTime.Size = New System.Drawing.Size(96, 24)
Me.BnGetSyncTime.TabIndex = 13
Me.BnGetSyncTime.Text = "GetSyncTime"
'
'GroupCanSpecial
'
Me.GroupCanSpecial.Controls.Add(Me.BnChipstate)
Me.GroupCanSpecial.Controls.Add(Me.BnGetSyncTime)
Me.GroupCanSpecial.Controls.Add(Me.Bn_ResetClock)
Me.GroupCanSpecial.Controls.Add(Me.BnRXQueueLevel)
Me.GroupCanSpecial.Controls.Add(Me.BnFlushTXQueue)
Me.GroupCanSpecial.Controls.Add(Me.BnFlushRXQueue)
Me.GroupCanSpecial.Location = New System.Drawing.Point(8, 184)
Me.GroupCanSpecial.Name = "GroupCanSpecial"
Me.GroupCanSpecial.Size = New System.Drawing.Size(328, 64)
Me.GroupCanSpecial.TabIndex = 14
Me.GroupCanSpecial.TabStop = False
'
'GroupAfterOpenPort
'
Me.GroupAfterOpenPort.Controls.Add(Me.Bn_ReceiveMode)
Me.GroupAfterOpenPort.Controls.Add(Me.BnCanAck)
Me.GroupAfterOpenPort.Controls.Add(Me.BnTxReceipt)
Me.GroupAfterOpenPort.Location = New System.Drawing.Point(8, 152)
Me.GroupAfterOpenPort.Name = "GroupAfterOpenPort"
Me.GroupAfterOpenPort.Size = New System.Drawing.Size(328, 40)
Me.GroupAfterOpenPort.TabIndex = 15
Me.GroupAfterOpenPort.TabStop = False
'
'Bn_ReceiveMode
'
Me.Bn_ReceiveMode.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Bn_ReceiveMode.Location = New System.Drawing.Point(216, 16)
Me.Bn_ReceiveMode.Name = "Bn_ReceiveMode"
Me.Bn_ReceiveMode.Size = New System.Drawing.Size(96, 24)
Me.Bn_ReceiveMode.TabIndex = 14
Me.Bn_ReceiveMode.Text = "Err:on Chip:on"
'
'Form1
'
Me.AllowDrop = True
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(824, 408)
Me.Controls.Add(Me.GroupAfterOpenPort)
Me.Controls.Add(Me.GroupAcceptance)
Me.Controls.Add(Me.Output)
Me.Controls.Add(Me.GroupBox3)
Me.Controls.Add(Me.GroupCANSetup)
Me.Controls.Add(Me.GroupCanMessage)
Me.Controls.Add(Me.GroupCanSpecial)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Form1"
Me.Text = "xlVBCANapp 1.41 (2006-06-20)"
Me.GroupCanMessage.ResumeLayout(False)
Me.GroupCANSetup.ResumeLayout(False)
Me.GroupBox3.ResumeLayout(False)
Me.GroupAcceptance.ResumeLayout(False)
Me.GroupCanSpecial.ResumeLayout(False)
Me.GroupAfterOpenPort.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Const appName As String = "xlVBCANapp"
Dim portHandle As UInt32 = Convert.ToUInt32(0)
Dim accessMask As System.UInt64 'means mask for all Channels
Dim MaxAssignedChannels As Byte = 64 'max 64 channels supported
'saves Channel Mask as Long (needed for BitOperations, coz UintXX not supported by .net)
Dim ChannelMask(XL_CONFIG_MAX_CHANNELS + 1) As Long
'needed for the CAN threading stuff -bac
Dim g_msgEvent As UInt64 = Convert.ToUInt64(0)
Dim g_RXThreadRun As Int16 = Convert.ToInt16(1)
Dim RxThread As New System.Threading.Thread(AddressOf ReceiveMessage)
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim xlstatus As Byte
Try
'open driver
xlstatus = xlOpenDriver()
If (xlstatus) Then
MessageBox.Show("xl!Error:OpenDriver:" & xlGetErrorString(xlstatus) & Chr(13), "xlVBCANapp Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
Catch ex As DllNotFoundException
Console.WriteLine("xlVBCANapp: Error: vxlapi.dll not found")
MessageBox.Show("vxlapi.dll not found", "xlVBCANapp Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End
End Try
InitDriver() ' init driver and port see function code
'init combobox values
CBoxHardwareType.Text = CBoxHardwareType.Items.Item(0)
CBoxCanMsgType.Text = CBoxCanMsgType.Items.Item(0)
CBox_RTRBit.Text = CBox_RTRBit.Items.Item(0)
' xlCanSetChannelBitrate - usable with init access only!
' if not set the parameter in Vector Hardware will used
Dim Bitrate As UInt32 = Convert.ToUInt32(33333) ' could set to 15'000 - 1'000'000
xlstatus = xlCanSetChannelBitrate(portHandle, accessMask, Bitrate)
If (xlstatus) Then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -