Quelques mots de remerciements seront grandement appréciés. Ajouter un commentaire
117 internautes nous ont dit merci ce mois-ci
Dim lValue as Long=0 lValue=MonTab(0) lValue*=256 lValue+=Montab(1) lValue*=256 lValue+=Montab(2) lValue*=256 lValue+=Montab(3)
Quelques mots de remerciements seront grandement appréciés. Ajouter un commentaire
117 internautes nous ont dit merci ce mois-ci
Quelques mots de remerciements seront grandement appréciés. Ajouter un commentaire
117 internautes nous ont dit merci ce mois-ci
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSend.Click Dim TabTrame() As Byte = New Byte() {&HFE, &H10, 0, &HA, 0, 2, 4, 0, &H64, 0, 0, &H80, &H94} 'trame réini compteur 1 , 10kWh SerialPort1.Write(TabTrame, 0, TabTrame.Length & vbCr) ' Le texte contenu dans le txtText est envoyé au port série comme trame en ASCII avec le retour chariot End Sub Private Sub cmbPort_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPort.SelectedIndexChanged If SerialPort1.IsOpen = False Then SerialPort1.PortName = cmbPort.Text 'Affiche un messagebox à l'utilisateur dès qu'il change de port Else 'sans s'être déconnecté au préalable. MsgBox("Port Ouvert", vbCritical) End If End Sub Private Sub cmbBaud_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbBaud.SelectedIndexChanged If SerialPort1.IsOpen = False Then SerialPort1.BaudRate = cmbBaud.Text 'Affiche un msgbox à l'utilisateur dès qu'il modifie la vitesse Else 'sans s'être déconnecté au préalable MsgBox("Port Ouvert", vbCritical) End If End Sub Private Sub BtnSend2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSend2.Click Dim trame2() As Byte = New Byte() {&HFE, &H10, 1, &H5E, 0, &HB, &H16, 0, &HA, &H1, &H2C, &H57, &H6B, &H0, &H68, &H1C, &HBA, &H68, &H5D, &H57, &H6B, &H68, 0, 0, 0, 0, 0, 0, 0, &HD5, &H16} Dim trame3() As Byte = New Byte() {&HFE, &H10, 1, &H72, 0, 1, 2, &H99, &H13, &HD2, &H2B} SerialPort1.Write(trame2, 0, trame2.Length) Threading.Thread.Sleep(200) SerialPort1.Write(trame3, 0, trame3.Length) End Sub End Class
Private Sub BtnIndex_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnIndex.Click Dim tcompteur8() As Byte = New Byte() {&HFE, 3, 1, &H60, 0, 9, &H90, &H21} Dim tcompteur7() As Byte = New Byte() {&HFE, 3, 1, &H4F, 0, 9, &HA1, &HE8} Dim tcompteur6() As Byte = New Byte() {&HFE, 3, 1, &H3E, 0, 9, &HF1, &HF3} Dim tcompteur5() As Byte = New Byte() {&HFE, 3, 1, &H2D, 0, 9, 0, &H36} Dim tcompteur4() As Byte = New Byte() {&HFE, 3, 1, &H1C, 0, 9, &H51, &HF9} Dim tcompteur3() As Byte = New Byte() {&HFE, 3, 1, &HB, 0, 9, &HE1, &HFD} Dim tcompteur2() As Byte = New Byte() {&HFE, 3, 0, &HFA, 0, 9, &HB9, &HF2} Dim tcompteur1() As Byte = New Byte() {&HFE, 3, 0, &HE9, 0, 9, &H40, &H37} SerialPort1.Write(tcompteur8, 0, tcompteur8.Length & vbCr) Threading.Thread.Sleep(350) SerialPort1.Write(tcompteur7, 0, tcompteur7.Length & vbCr) Threading.Thread.Sleep(350) SerialPort1.Write(tcompteur6, 0, tcompteur6.Length & vbCr) Threading.Thread.Sleep(350) SerialPort1.Write(tcompteur5, 0, tcompteur5.Length & vbCr) Threading.Thread.Sleep(350) SerialPort1.Write(tcompteur4, 0, tcompteur4.Length & vbCr) Threading.Thread.Sleep(350) SerialPort1.Write(tcompteur3, 0, tcompteur3.Length & vbCr) Threading.Thread.Sleep(350) SerialPort1.Write(tcompteur2, 0, tcompteur2.Length & vbCr) Threading.Thread.Sleep(350) SerialPort1.Write(tcompteur1, 0, tcompteur1.Length & vbCr) End Sub Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived Thread.Sleep(100) Dim b(18) As Byte 'b()=longeur de la trame de retour affichée en hexa Dim reponseindex As String = Nothing SerialPort1.Read(b, 0, 18) For ii As Integer = 0 To 18 'reponseindex = reponseindex & ":" & Hex(b(ii)) reponseindex = reponseindex & ":" & Chr(b(ii)) MsgBox(reponseindex) Next 'MessageBox.Show(reponseindex) Dim reptronque() As String Dim count As Integer 'Dim table() As String reptronque = reponseindex.Split(":") For count = 0 To reptronque.Length - 1 'table = reptronque 'MsgBox(reptronque(count)) Next End Sub Private Sub cmbPort_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbPort.SelectedIndexChanged If SerialPort1.IsOpen = False Then SerialPort1.PortName = CmbPort.Text 'Affiche un messagebox à l'utilisateur dès qu'il change de port Else 'sans s'être déconnecté au préalable. MsgBox("Port Ouvert", vbCritical) End If End Sub Private Sub cmbBaud_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbBaud.SelectedIndexChanged If SerialPort1.IsOpen = False Then SerialPort1.BaudRate = CmbBaud.Text 'Affiche un msgbox à l'utilisateur dès qu'il modifie la vitesse Else 'sans s'être déconnecté au préalable MsgBox("Port Ouvert", vbCritical) End If End Sub Private Sub BtnSend2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSend2.Click Dim trame2() As Byte = New Byte() {&HFE, &H10, 1, &H5E, 0, &HB, &H16, 0, &HA, &H1, &H2C, &H57, &H6B, &H0, &H68, &H1C, &HBA, &H68, &H5D, &H57, &H6B, &H68, 0, 0, 0, 0, 0, 0, 0, &HD5, &H16} Dim trame3() As Byte = New Byte() {&HFE, &H10, 1, &H72, 0, 1, 2, &H99, &H13, &HD2, &H2B} 'Modification temps d'intégration voie 5 à t=5mn SerialPort1.Write(trame2, 0, trame2.Length) Threading.Thread.Sleep(200) SerialPort1.Write(trame3, 0, trame3.Length) End Sub End Class
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.