Skip to content

miyako/4d-plugin-serial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

version platform license downloads

4d-plugin-serial

armadsen/ORSSerialPort 2.1.0を使用しています。

ただし,シリアルポート付け外しの通知を受け取るため,CFRunLoopGetCurrentCFRunLoopGetMainに書き換えてビルドしました。

用途

標準コマンドのRECEIVE BUFFERは非Unicodeモードの遺物であり,BLOBに対応していません。

一方,RECEIVE PACKETはバックグランドで「待ち受け」することができません。

プラグインは,スリープの開始と解除・シリアルポートの取り外しと取り付けに反応し,バイナリデータを扱うことができます。

例題

$ports:=SERIAL Get available ports

$usbserial:=$ports.query("path == :1"; "/dev/cu.usbserial@")

If ($usbserial.length#0)
	
	$path:=$usbserial[0].path
	
	$options:=New object
	
	$status:=SERIAL Open path($path; $options; "serial_receive_method")
	
	var $data : Blob
	
	SET BLOB SIZE($data; 10)
	
	$status:=SERIAL Send data($path; $data)
	
	$status:=SERIAL Close path($path)
	
End if 

SERIAL Get available ports

ports:=SERIAL Get available ports()
パラメーター データ型 説明
ports[] Collection シリアルポート
ports[] Collection
ports[].allowsNonStandardBaudRates Boolean
ports[].baudRate Number
ports[].CTS Boolean
ports[].DCD Boolean
ports[].DSR Boolean
ports[].DTR Boolean
ports[].isOpen Boolean
ports[].name Text
ports[].numberOfStopBits Number
ports[].parity Text none odd even
ports[].path Text
ports[].RTS Boolean
ports[].shouldEchoReceivedData Boolean
ports[].usesDCDOutputFlowControl Boolean
ports[].usesDTRDSRFlowControl Boolean
ports[].usesRTSCTSFlowControl Boolean

SERIAL Open path

status:=SERIAL Open path(path{;options})
パラメーター データ型 説明
status Object
status.success Boolean
status.port Object

シリアル通信コールバック実行用のプロセス$SERIALが起動します。

process

シリアル通信を受信すると,下記のパラメーターでコールバックメソッドが実行されます。

#DECLARE($path : Text; $data : Blob)

SERIAL Close path

status:=SERIAL Close path(path)
パラメーター データ型 説明
status Object
status.success Boolean

SERIAL Send data

status:=SERIAL Send data(path)
パラメーター データ型 説明
status Object
status.success Boolean

動作検証

USB⇄RS-232Cコンバーター チップ VCM Driver macOS 4D 対応
REX-USB60F FTDI 2.4.4 Catalina 19 OK
2.4.4 Monterey arm64 19 ×
2.4.4 Monterey rosetta 19 ×
1.4.7 Monterey arm64 19 ×
1.4.7 Monterey rosetta 19 ×