Read serial flow USB - Serial.ahk

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Albireo
Posts: 1778
Joined: 16 Oct 2013, 13:53

Read serial flow USB - Serial.ahk

Post by Albireo » 03 Dec 2019, 18:17

Is it possible to read what communication values the USB-port have on this computer?
(eg. COM3 = 19200, N ,8, 1)

Is it possible to read the name on the COM-port from the device manager?
(eg. Arduino Uno (COM3) )

Don't know if I found the latest version of Serial.ahk or Arduino.ahk
Is there any documentation that describes what these files do / should do?
What is the difference between these files?

Trying to read information that is constantly flowing through USB from the Arduino.
With this AHK-program example .:
Serial read Arduino
How do I know that all bytes in the bit-flow are read only once? (it seems so)
How to know if a new value can be read from the COM-port?

Created a Loop that would read the entire byte sequence transmitted through the COM port.
But something happens that I do not understand.

Code: Select all

Loop 100
{	ReadResult := Serial_Read(COM_FileHandle, Num_Bytes, Mode)
	asciiString := Hex2ASCII(ReadResult)
	FileAppend %asciiString%, %FilNamn%, UTF-8
	Sleep 50
	; MsgBox ,, Rad %A_LineNumber% -> %A_ScriptName%, % COM_Settings "`n`n" ReadResult "`n`n- " StrLen(ReadResult) "`n`n- " Bytes_Received "`n`n- " asciiString, 1
}
The result was .: But:322
Buttons A:1 B:1 C:1 D:1 E:1 F:1 -- Position X:334 Y:322
334 Y:322
Buttons A:1 B:1 C:1 D:1 E:1 F:1 -- Position X:334 Y:322
Buttons A:1 B:1 C:1 D:1 E:1 F:1 -- Position X:334 Y:322
Buttons A:1 B:1 C:1 D:1 E:1 F:1 -- Position X:335 Y:322
Buttons A:1 B:1 C:1 D:1 E:1 F:1 -- Position X:334 Y:321
Buttons A:1 B:1 C:1 D:1 E:1 F:1 -- Position X:334 Y:322
Buttons A:1 B:1 C:1 D:1 E:1 F:1 -- Position X:334 Y:321
Buttons A:1 B:1 C:1 D:1 E:1 F:1 -- Position X:334 Y:322

Time seems to be required before the flow is read correctly (even though the speed is only 9600 bps)
Why didn't I get 100 readings?
Is the only way to create your own "handshake" with the Arduino to get a safe reading?

User avatar
iilabs
Posts: 296
Joined: 07 Jun 2020, 16:57

Re: Read serial flow USB - Serial.ahk

Post by iilabs » 07 Oct 2023, 17:52

Hello, did you ever find the answer on how to communicate with Arduino and ahk? If so please post. I

Albireo
Posts: 1778
Joined: 16 Oct 2013, 13:53

Re: Read serial flow USB - Serial.ahk

Post by Albireo » 08 Oct 2023, 02:46

No.
I gave up, but still hoping for a solution.
I think it's strange that it was so difficult.

Post Reply

Return to “Ask for Help (v1)”