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

📄 pcan_light_frm.frm

📁 通过Peak和Can总线通讯
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "PCAN_Light USB Test Visual Basic (c) PEAK-System Technik GmbH"
   ClientHeight    =   5895
   ClientLeft      =   165
   ClientTop       =   600
   ClientWidth     =   11400
   LinkTopic       =   "Form1"
   ScaleHeight     =   5895
   ScaleWidth      =   11400
   StartUpPosition =   3  '窗口缺省
   Begin VB.Timer Timer1 
      Interval        =   10
      Left            =   3360
      Top             =   0
   End
   Begin VB.ListBox List1 
      Height          =   1860
      ItemData        =   "PCAN_Light_FRM.frx":0000
      Left            =   120
      List            =   "PCAN_Light_FRM.frx":0002
      MousePointer    =   2  'Cross
      MultiSelect     =   2  'Extended
      TabIndex        =   20
      Top             =   3720
      Width           =   7095
   End
   Begin VB.TextBox Text1 
      BeginProperty DataFormat 
         Type            =   1
         Format          =   "###"
         HaveTrueFalseNull=   0
         FirstDayOfWeek  =   0
         FirstWeekOfYear =   0
         LCID            =   1031
         SubFormatType   =   0
      EndProperty
      Height          =   375
      Left            =   2640
      TabIndex        =   14
      Top             =   2280
      Width           =   615
   End
   Begin VB.Frame Frame4 
      Height          =   735
      Left            =   3600
      TabIndex        =   9
      Top             =   1800
      Width           =   3615
      Begin VB.CommandButton Command4 
         Caption         =   "CAN_Close"
         Height          =   375
         Left            =   120
         TabIndex        =   10
         Top             =   240
         Width           =   1335
      End
      Begin VB.Label Label4 
         Height          =   255
         Left            =   1800
         TabIndex        =   11
         Top             =   360
         Width           =   1095
      End
   End
   Begin VB.Frame Frame3 
      Height          =   735
      Left            =   3600
      TabIndex        =   6
      Top             =   960
      Width           =   3615
      Begin VB.CommandButton Command3 
         Caption         =   "CAN_Status"
         Height          =   375
         Left            =   120
         TabIndex        =   7
         Top             =   240
         Width           =   1335
      End
      Begin VB.Label Label3 
         Height          =   255
         Left            =   1800
         TabIndex        =   8
         Top             =   240
         Width           =   1455
      End
   End
   Begin VB.CommandButton Command2 
      Caption         =   "CAN_Init"
      Height          =   375
      Left            =   3720
      TabIndex        =   3
      Top             =   360
      Width           =   1335
   End
   Begin VB.CommandButton Command1 
      Caption         =   "CAN_VersionInfo"
      Height          =   375
      Left            =   240
      TabIndex        =   0
      Top             =   360
      Width           =   1455
   End
   Begin VB.Frame Frame1 
      Height          =   1815
      Left            =   120
      TabIndex        =   1
      Top             =   120
      Width           =   3375
      Begin VB.Label Label1 
         Height          =   975
         Left            =   120
         TabIndex        =   2
         Top             =   720
         Width           =   3135
      End
   End
   Begin VB.Frame Frame2 
      Height          =   735
      Left            =   3600
      TabIndex        =   4
      Top             =   120
      Width           =   3615
      Begin VB.Label Label2 
         Height          =   375
         Left            =   1680
         TabIndex        =   5
         Top             =   240
         Width           =   1455
      End
   End
   Begin VB.Frame Frame5 
      Height          =   1335
      Left            =   120
      TabIndex        =   12
      Top             =   2040
      Width           =   3375
      Begin VB.CommandButton Command5 
         Caption         =   "CAN_Write"
         Height          =   375
         Left            =   120
         TabIndex        =   13
         Top             =   240
         Width           =   1455
      End
      Begin VB.Label Label9 
         Caption         =   "ID:"
         Height          =   255
         Left            =   2160
         TabIndex        =   19
         Top             =   360
         Width           =   255
      End
      Begin VB.Label Label8 
         Height          =   255
         Left            =   1680
         TabIndex        =   18
         Top             =   360
         Width           =   255
      End
      Begin VB.Label Label7 
         Caption         =   "Len: 8      Data:"
         Height          =   255
         Left            =   120
         TabIndex        =   17
         Top             =   720
         Width           =   1455
      End
      Begin VB.Label Label6 
         Caption         =   "0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80"
         Height          =   255
         Left            =   120
         TabIndex        =   16
         Top             =   960
         Width           =   3135
      End
   End
   Begin VB.Label LblConvert 
      Caption         =   "Label15"
      Height          =   735
      Left            =   8160
      TabIndex        =   26
      Top             =   480
      Width           =   6135
   End
   Begin VB.Label Label14 
      Height          =   255
      Left            =   4560
      TabIndex        =   25
      Top             =   3360
      Width           =   2655
   End
   Begin VB.Label Label13 
      Caption         =   "CAN Msg磗:"
      Height          =   255
      Index           =   1
      Left            =   3600
      TabIndex        =   24
      Top             =   3360
      Width           =   855
   End
   Begin VB.Label Label12 
      Caption         =   "PCAN_Light Test (c) 2001 PEAK-System Technik"
      Height          =   375
      Left            =   3600
      TabIndex        =   23
      Top             =   2640
      Width           =   3615
   End
   Begin VB.Label Label11 
      Height          =   255
      Left            =   4680
      TabIndex        =   22
      Top             =   3000
      Width           =   855
   End
   Begin VB.Label Label10 
      Caption         =   "CAN_Read:"
      Height          =   255
      Index           =   0
      Left            =   3600
      TabIndex        =   21
      Top             =   3000
      Width           =   855
   End
   Begin VB.Label Label5 
      Caption         =   "ID:"
      Height          =   255
      Left            =   240
      TabIndex        =   15
      Top             =   2880
      Width           =   375
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


Private Sub Command1_Click()
 Dim Version As String * 255
 ret = CAN_VersionInfo(Version)
 Label1.Caption = Version
End Sub

Private Sub Command2_Click()
 ret = CAN_Init(CAN_BAUD_500K, CAN_INIT_TYPE_ST)
 Label2.Caption = ret
 List1.Clear
End Sub

Private Sub Command3_Click()
 ret = CAN_Status()
 Label3.Caption = ret
End Sub

Private Sub Command4_Click()
 ret = CAN_Close()
 Label4.Caption = ret
End Sub

Private Sub Command5_Click()
If Text1.Text = "" Then
 Text1.Text = &H100
End If
 Dim myMsg As TPCANMsg
 myMsg.ID = Text1.Text
 myMsg.MSGTYPE = 0
 myMsg.LEN = 8
 myMsg.DATA(0) = &H10
 myMsg.DATA(1) = &H20
 myMsg.DATA(2) = &H30
 myMsg.DATA(3) = &H40
 myMsg.DATA(4) = &H50
 myMsg.DATA(5) = &H60
 myMsg.DATA(6) = &H70
 myMsg.DATA(7) = &H80
 ret = CAN_Write(myMsg)
 Label8 = ret
End Sub



Private Sub Timer1_Timer()
 
 Dim myMsg As TPCANMsg
 Static MsgCounter
 Dim sRecord1 As String
 ret = CAN_Read(myMsg)
 Rem solange wie CAN_ERR_OK....(aslo Nachrichten vorhanden..wenn keine dann CAN_ERR_QRCVEMPTY
 While (ret = CAN_ERR_OK)
   MsgCounter = MsgCounter + 1
     sRecord1 = "ID: " + Format(Hex(myMsg.ID), "@@@@@@@@") + ",  LEN: " + Hex(myMsg.LEN)
Buffer = "ID: " + Format(Hex(myMsg.ID), "###000 ") + "LEN: " + Format(Hex(myMsg.LEN), "#0 ")
   'Buffer = "ID: " + Format(myMsg.ID, "###000 ") + "LEN: " + Format(myMsg.LEN, "#0 ")
   For i = 0 To myMsg.LEN - 1
   sRecord1 = sRecord1 + " " + Hex(myMsg.DATA(i))
     Buffer = Buffer + " " + Format(Hex(myMsg.DATA(i)), "###000")
      'Buffer = Buffer + " " + Format(myMsg.DATA(i), "###000")
   Next
   List1.AddItem (Buffer)
   LblConvert.Caption = sRecord1
   ret = CAN_Read(myMsg)
 Wend
 Label11.Caption = ret
 Label14.Caption = MsgCounter
End Sub

⌨️ 快捷键说明

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