2015년 11월 9일 월요일

Simple Example RS-232(c) Code for Lua (MAC)


* Simple Exmaple Code RS-232(c) for Lua (MAC)

wserial = io.open("/dev/cu.usbserial-FTGGOX8Z","w")
rserial = io.open("/dev/cu.usbserial-FTGGOX8Z","r")
rserial:setvbuf("line",100)
COMMAND = "*RST\n"
wserial:write(COMMAND)
COMMAND = "*IDN?\n"
wserial:write(COMMAND)
data = rserial:read()
print(data)
rserial:flush()
COMMAND = ":SYST:CLE\n"
wserial:write(COMMAND)
COMMAND = ":SYST:ERR?\n"
wserial:write(COMMAND)
data = rserial:read()
print(data)
rserial:flush()
COMMAND = ":SYST:ZCHK OFF\n"
wserial:write(COMMAND)
COMMAND = ":OUTP ON\n"
wserial:write(COMMAND)
for i = 1, 10 do
  COMMAND = ":READ?\n"
  wserial:write(COMMAND)
  data = rserial:read()
  print(data)
  rserial:flush()
end
rserial:close()
COMMAND = ":SYST:ZCHK ON\n"
wserial:write(COMMAND)
COMMAND = ":OUTP OFF\n"
wserial:write(COMMAND)

wserial:close()

댓글 없음:

댓글 쓰기

네티켓 아시져 -ㅁ-?