Hallo,
ich habe hier einen AppleScript der über USB die Daten seriell empfängt.
Das Problem ist, das alles SchneckeLangsam ist.
Kann AppleScript das nicht schneller, was bremst denn hier?
Auch der Empfang läuft nicht richtig- empfangen werden sollte:
“24330” Siehe Bild
Es wird aber immer zerhackt. Lieferant ist ein Arduino.
Gruß und Dank
Andreas
Der Script:
set onMode to false
set use_port to "/dev/cu.usbmodem411"
repeat until (get serialport list) contains use_port
delay 3
end repeat
if (get serialport list) contains use_port then
set onMode to true
set myPort to serialport open use_port bps rate 9600 data bits 8 parity 0 stop bits 1 handshake 0
delay 1
if myPort is equal to -1 then
display dialog "could not open port"
else
repeat while onMode is true
set x to serialport read myPort
if x is not equal to "" then
--beep
if x = "q" then
display dialog "Quitting"
serialport close myPort
exit repeat
end if
end if
end repeat
end if
serialport close myPort
end if
Hab da mal noch den Syntax-Highlighter zugeschaltet.
Hm… das mit dem Zerhacken ist blöd - hast Du auf dem seriellen Port evtl. doch Hardware-Handshake?
Eigentlich ist das Skript zu schnell, wenn es die Antwort so in Einzelteilen liefert - der Read-Befehl weiß halt nicht, wie viele Bytes kommen, und speichert dann „irgendwann“ das Ergebnis in x.
Was ist das für eine Version des Plugins für den seriellen Port?
Hallo,
welches plugin?
Das “/dev/cu.usbmodem411” ist die ArduinoSchnittstelle der Arduino IDE.
Mit ne´m TerminalProgramm rauscht das einfach alles richtig durch.
Es muß doch möglich sein, das in einer schnellen Schleife laufen zu lassen?
Ich habs mal umgefummelt, das selbe Ergebnis…
Gruß und Dank
Andreas
set onMode to false
set use_port to “/dev/cu.usbmodem411”
repeat until (get serialport list) contains use_port
delay 3
end repeat
if (get serialport list) contains use_port then
set onMode to true
set myPort to serialport open use_port bps rate 9600 data bits 8 parity 0 stop bits 1 handshake 0
delay 1
if myPort is equal to -1 then
display dialog “could not open port”
end if
try
repeat
set x to serialport read myPort
end repeat
end try