Serial Communication Toolbox for Scilabopenserial.sci
リポジトリからを見ると、
function h=openserial(p,smode,translation,handshake,xchar,timeout)
//port name
if ~exists("p","local") then p=1; end
if type(p)==1 | type(p)==8 then
if p<=0 then error("port number must be greater than zero"); end
if getos() == "Windows" then
port="COM"+string(p)+":"
else
port="/dev/ttyS"+string(p-1)
end
elseif type(p)==10
port=p
else
error("port to open must be either a number or a string")
end
ポートは常に に設定されてい/dev/ttyS<PORT_NUMBER>
ます。したがって、ローカルのツールボックス ファイルで、次の行を次のように編集してみてくださいopenserial.sci
。
function h=openserial(p,smode,translation,handshake,xchar,timeout)
//port name
if ~exists("p","local") then p=1; end
if type(p)==1 | type(p)==8 then
if p<=0 then error("port number must be greater than zero"); end
if getos() == "Windows" then
port="COM"+string(p)+":"
else
port="/dev/ttyS"+string(p-1)
end
elseif type(p)==10
port=p
elseif type(p)=="ACM0"
port="/dev/ttyACM0"
else
error("port to open must be either a number or a string")
end
次に、openserial を次のように呼び出します。
h=openserial("ACM0","9600,n,8,1)
また、それ/dev/ttyACM0
が正しいデバイス ノードであることも確認してください。これは、ls -l
確認のために実行できるからの出力例です。
$ ls -l /dev/ttyACM0
crw-rw---- 1 root dialout 188, 0 Mar 12 18:16 /dev/ttyACM0
通常のユーザーとしてシリアル ポートを開くときにエラーが発生する場合は、自分自身を正しいグループに追加することができます。上記の例に基づくと、グループ名はdialout
私の openSUSE ディストリビューションにあります。お使いのものとは異なる場合があるため、次のコマンドでそのグループ名を置き換えます。
sudo usermod -a -G dialout <USER_NAME>