Coder Social home page Coder Social logo

mruby-serialport's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mruby-serialport's Issues

Running the example

I am pretty new to mruby. I want to run a serialport program from my raspberry pi to a ARM Cortex M4, which has been programmed to perform some tasks upon some instructions. I want to provide the instructions from a mruby program. My build_config.rb looks like this.

############################
# Start of your build_config

MRuby::Build.new do |conf|
  toolchain :gcc

  conf.bins = %w(mrbc)

  # mruby's Core GEMs
  conf.gem 'mrbgems/mruby-bin-mirb'
  conf.gem 'mrbgems/mruby-bin-mruby'
  conf.gem 'mrbgems/mruby-array-ext'
  conf.gem 'mrbgems/mruby-enum-ext'
  conf.gem 'mrbgems/mruby-eval'
  conf.gem 'mrbgems/mruby-exit'
  conf.gem 'mrbgems/mruby-fiber'
  conf.gem 'mrbgems/mruby-hash-ext'
  conf.gem 'mrbgems/mruby-math'
  conf.gem 'mrbgems/mruby-numeric-ext'
  conf.gem 'mrbgems/mruby-object-ext'
  conf.gem 'mrbgems/mruby-objectspace'
  conf.gem 'mrbgems/mruby-print'
  conf.gem 'mrbgems/mruby-proc-ext'
  conf.gem 'mrbgems/mruby-random'
  conf.gem 'mrbgems/mruby-range-ext'
  conf.gem 'mrbgems/mruby-sprintf'
  conf.gem 'mrbgems/mruby-string-ext'
#  conf.gem 'mrbgems/mruby-string-utf8'
  conf.gem 'mrbgems/mruby-struct'
  conf.gem 'mrbgems/mruby-symbol-ext'
  conf.gem 'mrbgems/mruby-time'
  conf.gem 'mrbgems/mruby-toplevel-ext'

  # user-defined GEMs
  conf.gem :git => 'https://github.com/monami-ya-mrb/mruby-serialport.git'
end

# End of your build_config
############################

Then I aaded unistd.h and string.h in serport-impl-posix.c in mruby/build/mrbgems/mruby-serialport/src to avoid some errors of undefined function declarations. Then I did this
sudo rake
And it was successfully built.
Now I see a serialport.rb file in the test directory of the gem which is similar to what I write in ruby for serialport programming. Hence, I changed it a bit to write some characters to the serialport where my ARM Controller has been connected. My serialport.rb looks like this.

assert("serial") do
  sp = SerialPort.new("/dev/ttyACM0", 115200, 8, 1, 0)
  sp.read_timeout=1000
  wait_time = 4
  sp.puts "foobarbaz"
  sp.gets == "foobarbaz\n"
  list = ["f", "l", "r", "b", "s"]
  list.each do |l|
    sp.write(l)
    sleep wait_time
  end
end

After this when I read about the five ways to run a mruby program and tried the first one with mruby compiler for running pure ruby code like "mruby serialport.rb" , I get the error like this

    [0] ../test/serialport.rb:1
../test/serialport.rb:1: undefined method 'assert' for main (NoMethodError)

I have been following so many forums for this. If anybody please explain me how can I achieve this, I will be obliged. ๐Ÿ˜ƒ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.