Je change ma question de catégorie, je m'étais trompé...désolé...
Bonjour,
En tant qu'autodidacte en visual basic, j'ai besoin d'aide concernant un point sur lequel je bute depuis quelque temps.
J'ai acquis un système de vote à fréquence radio. Il s'agit de plusieurs émetteurs sans fil et un récepteur connecté en USB (port COM émulé).
Ce système a l'avantage de proposer un SDK, ce qui m'a permis de créer mon propre programme, en reprenant les codes et la .dll fournis par le constructeur.
Etant encore débutant en vb6 à l'époque, je me suis fait aider par l'assistance technique du constructeur (aux US) afin d'avoir un programme « de base » qui tient la route (ils étaient pas obligés de le faire).
Seulement voilà : le système supposé pouvoir recevoir plus de 1000 votes à la seconde ne réagit pas super bien avec le petit programme qu'on m'a fourni : dans le cas de votes simultanés il arrive très fréquemment que cela génère un conflit et que les informations n'arrivent pas.
J'ai envoyé un mail au type qui m'a aidé pour lui signaler ce qui m'est arrivé et il m'a répondu ceci :
If you are using the MSComm control you may have better results if you configure it to interrupt on each character and in the OnComm Event store the received character in a FIFO.<?xml:namespace prefix
o ns "urn:schemas-microsoft-com:office:office" /??>
Then from a timer Event load an array from the FIFO to be passed to hitt_inspect, if hitt_inspect returns HITT_ERROR then shift your array elements up by one and add one value from the FIFO to the end of the array and call hitt_inspect again. You may want to do this in a "While Loop", until hitt_inspect returns HITT_OK.
If you are using the CommIO from here...
http://www.thescarms.com/VBasic/CommIO.asp you would do basically the same thing, except you would load the FIFO from a separate timer Event to read the comm.
The example FIFO uses the variant data type, so you should probably change this to the proper type depending on which Com I/O setup you are using, for best performance.
I hope this helps.
Je vois à peu près ce qu'il veut dire, mais je ne sais absolument pas écrire un programme de ce genre ou même adapter celui existant, quelqu'un peut-il m'aider svp ??? Je vous remercie d'avance..
PS : voici le code du programme que j'utilise actuellement.
Dans main.frm (un objet Textbox appelé Text1, un objet Listbox appelé List1, un objet MSComm appelé MSComm2) :
Option Explicit
Dim RecData() As Byte
Dim Key As Long
Dim Id As Long
Dim Result As Long
Private Sub Form_Load()
With MSComm2
.CommPort = 5 'Adjust as needed
.Handshaking = 0
.RThreshold = 10 ' ici ce qui doit poser problème, non ??
.RTSEnable = False
.Settings = "19200,n,8,1" 'Adjust as needed
.SThreshold = 1
.InputMode = comInputModeBinary
.PortOpen = True
End With
Text1.Text = ""
List1.Text = ""
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSComm2.PortOpen = False
End Sub
Private Sub MSComm2_OnComm()
Select Case MSComm2.CommEvent
Case comEvReceive
RecData = MSComm2.Input
Result = hitt_inspect(RecData(0), Id, Key)
If Result = HITT_OK Then
Text1.Text = "Remote ID: " & CStr(Id) & ", Key: " & CStr(Key)
List1.AddItem "Remote ID: " & CStr(Id) & ", Key: " & CStr(Key)
Else
List1.AddItem "not received"
End If
End Select
End Sub
Dans Module1 (h-ittsdk.vb) :
Public Const HITT_ERROR As Long = 1
Public Const HITT_OK As Long = 0
Declare Function hitt_inspect Lib "h-ittsdk.dll" (ByRef Bytes As Byte, ByRef Id As Long, ByRef key_code As Long) As Long