Comm32 Logo
Home Button  Buy Button 

Topic:   Byte Receive Error from Arduino DUE

By: VladimirPosted on: Sep 6 2019 at 11:58:49 PM
I transfer about 80 kilobytes of binary packed information to Scomm in blocks of 4 bytes, the reception in Excel VBA according to your recommendation looks like this (after opening the port in inputMode = 1-inputModeBinary, InputLen = 2 mode, the settings are made in the Scomm Icon properties on the form).
Private Sub ArduinoDue_OnComm ()
Dim BBB () As Byte
Dim i as long
Select Case ArduinoDue.CommEvent
Case comEvReceive
Do While ArduinoDue.InBufferCount> 0
BBB = ArduinoDue.Input
BI = UBound (BBB) ​​'Len (ArduinoDue.Input)' Read)
'If (BI> = 0) Then
If (BI> 0) Then
For i = 0 To BI
If first then
Sb (0) = BBB (i) 'ArduinoDue.Input' Read '
Sbb (USbb) = Sb (0)
Else
Sb (1) = BBB (i) 'ArduinoDue.Input' Read '
Sbb (USbb) = Sb (1)
If ((Sb (0) = 255) And (Sb (1) = 255)) Then
KB = 0
BI = ArduinoDue.InBufferCount
ArduinoDue.InBufferCount = 0
ArduinoDue.Break = False
UserForm1.CommandButton1.Enabled = False
Exit do
End if
End if
First = Not First
USbb = USbb + 1
Next i
End If 'If (BI> 0) Then
Loop 'Do While ArduinoDue.InBufferCount> 0
Case Is> 1000
UserForm1.TextBox1.Value = "ComPort Error occurred."
Case else
Debug.Print "er?"
End select
End sub

Dim Sb (0 To 1) As Byte
Dim Sbb (0 To 180,000) As Variant 'Byte' Arduino 30,000 * 4 = 120,000
Dim USbb As Long

Dim BI As Long
I want to stop reception after two bytes of FF appear in the stream
as a result, in the Sbb buffer there are (after parsing) such transformed
in hexadecimal four bytes, sometimes "supplemented" by a huge amount of 0!
About 200 out of 20,000 fours
1.84016E + 11
18451600000
19301500000
94910000000
8.33E + 102
8.22E + 101

A parsing that produces such “eight” hexadecimal looks like this:
K = 1
Prot4 (0) = 0: Prot4 (1) = 0: Prot4 (2) = 0: Prot4 (3) = 0
Co = 0
B = usbb
For j = 0 To B '
Prot1 = Sbb (j)
' assembly of 4 bytes
Co = Co Mod 4
If (Co = 0) And (j> 2) Then
S2 = ""
For i = 0 To 3 'rearranged in Arduino !!!
S1 = Hex (Prot4 (i))
If Len (S1)

Please tell me what I'm doing wrong.
OR THIS WITH THE PORT SOMETHING IS NOT SO.
Speed 115200, N, 8.1

I will be very grateful. Byte transfer saves experience time,
in TextMode everything works (with reconfiguration) but ~12 bytes instead of 4!

Reply - add a comment to this topic.

You may enter letters, numbers and standard punctuation only. HTML and other scripts/tags will be rejected.

Topic:- Byte Receive Error from Arduino DUE


Enter the numbers.

Your name here is optional