望着openserial.sci
從Serial Communication Toolbox for Scilab回購,
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
如果您收到錯誤打開串口作爲一個普通用戶,你可以自己添加到正確的組。基於上述示例,我的openSUSE發行版中的組名是dialout
。這可能是對你的不同,在下面的命令,以便替換該組名稱:
sudo usermod -a -G dialout <USER_NAME>
Tuxdude,我沒你sugest什麼,我得到的以下使者: - 錯誤999 TCL_EvalStr,在1號線 \t無法打開 「ACM0」:執行 沒有這樣的文件或目錄 「開放ACM0 R +」 從 中調用「設置porthandle [開ACM0 R + ]「 在函數openserial的第17行調用: h = openserial(」ACM0「,」9600,n,8,1「) – 2013-03-21 00:30:06
@FabioSilva - 你確定你的串口設備節點是'/ dev/ttyACM0' ? – Tuxdude 2013-03-21 00:40:53
我從arduino IDE獲取這些信息。 – 2013-03-21 00:56:55