c - 如何在 Shoes 中使用嵌入式 c? ( ruby 串口)

标签 c ruby shoes embedded-language

是否可以使用类似的东西:

require 'serialport.o'

穿鞋? serialport.o 是编译为 ruby​​ 扩展的 c 代码。

当我尝试在鞋子中运行以下代码时,我在屏幕上看不到任何可见的输出,而且鞋子在 OS X 上崩溃了。

谢谢

代码:

require "serialport.o"

port = "/dev/tty.usbserial-A1001O0o"

sp = SerialPort.new( port, 9600, 8, 1, SerialPort::NONE)

Shoes.app :width => 300, :height => 150, :margin => 10 do
  button "On" do
  sp.write( "1" )
  end
end

sp.close

最佳答案

您可能已经检查过了,但是如果您不使用 Shoes,同样的方法是否有效?例如:

require "serialport.o"

port = "/dev/tty.usbserial-A1001O0o"
sp = SerialPort.new( port, 9600, 8, 1, SerialPort::NONE)
sp.write( "1" )
sp.close

关于c - 如何在 Shoes 中使用嵌入式 c? ( ruby 串口),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/347664/

相关文章:

c - 数组维度中的“const”值

C/预处理器 : detect if a __builtin function is available

ruby - 使用 "sudo gem update"的长期后果是什么?

ruby - 如何传递/获取命令行参数?

ruby 鞋。如何包含 Windows 依赖项

c - 使用指针的段错误 (SIGSEGV)

c - 如何向 GCC 提示某行在编译时不可达?

ruby-on-rails - ActiveRecord 匿名范围

ruby - 不能通过包含模块来重新定义类的实例方法吗?

ruby - 我无法在 Ubuntu 14 中安装 ShoesRB。问题是 .run 或 .install 文件类型吗?