Coder Social home page Coder Social logo

gnu-octave / octave-arduino Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 1.0 1.03 MB

Basic Octave implementation of the matlab arduino extension, allowing communication to a programmed arduino board to control its hardware.

Home Page: https://gnu-octave.github.io/octave-arduino/

License: GNU General Public License v3.0

Makefile 1.29% MATLAB 79.55% Objective-C 2.54% C++ 15.90% M 0.72%
arduino octave

octave-arduino's People

Contributors

i7tiol avatar lostbard avatar oheim avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

octave-arduino's Issues

V0.12.0 introduces connection issue

I have an Arduino mega2560 board and it works fine with V0.11.0 including an add-on I wrote. However, when testing things with V0.12.0, I cannot connect with the Arduino anymore. It doesn't seem to be add-on related and I could break it down to simply trying to run scanForArduinos twice in a row without any custom add-ons in the path. V0.11.0 simply gives me the connected device twice. V0.12.0 only works in the first call after arduinosetup() and results in an empty cell afterwards. Trying the 'debug' option gives me: "** initArduino: failed valid response err=1 - Undersized packet header". Could it be that scanForArduinos() doesn't release the connection properly?

Can't make arduino object with a Mac

I'm new to using a Mac (MacBook Pro, Sonoma 14.4) but have experience with Octave and Arduino in Windows. After pkg load arduino I can see this:

Package Name        | Version | Installation directory
--------------------+---------+-----------------------
           arduino *|  0.12.1 | .../cathy.zupke/.local/share/octave/api-v58/packages/arduino-0.12.1
instrument-control *|   0.9.2 | .../.local/share/octave/api-v58/packages/instrument-control-0.9.2
>>
The Octave version is:
>> version
ans = 8.4.0
>>

I can run arduinosetup and it will open the Arduino IDE and let me upload the code to an Arduino Uno board. That board can then work with Octave on a Windows machine, but when I try to make a connection on the MacBook I get this:

>> a=arduino('/dev/cu.usbmodem14201')
error: __initArduino__: failed get lib 1 err=1 - Undersized packet header
error: called from
    __initArduino__ at line 114 column 12
    arduino at line 133 column 16
>>

While more rare, I've also seen this:

>> a=arduino('/dev/cu.usbmodem14201')
error: set: H must be a graphics handle
>>

Unplugging the board and plugging it back in seems to restore it to the "Undersized packet header" state.

For what it is worth, when installing the instrument-control package, there were a lot of warnings but as far as I could tell, no errors.

test @arduino/arduino fail

Running test @arduino/arduino while Arduino (redboard by sparkfun) plugged in (/dev/ttyUSB0):

octave:2> test @arduino/arduino verbose
>>>>> /home/dima/.local/share/octave/api-v59/packages/arduino-0.12.1/@arduino/arduino.m
***** shared arduinos
 arduinos = scanForArduinos(1);
***** assert(numel(arduinos), 1);
***** test
 ar = arduino();
 assert(!isempty(ar));
 assert(ar.port, arduinos{1}.port);
 assert(ar.board, arduinos{1}.board);
 assert(numel(ar.availablepins) > 0);
***** test
 ar = arduino(arduinos{1}.port);
 assert(!isempty(ar));
 assert(ar.port, arduinos{1}.port);
 assert(ar.board, arduinos{1}.board);
***** test
 ar = arduino(arduinos{1}.port, arduinos{1}.board);
 assert(!isempty(ar));
 assert(isa(ar, "arduino"))
 assert(ar.port, arduinos{1}.port);
 assert(ar.board, arduinos{1}.board);
***** test
 ar = arduino();
 # verify have compiled support for functions we will be testing
 assert(!isempty(find(cellfun(@(x) strcmpi(x, "spi"), ar.libraries()), 1)))
 assert(!isempty(find(cellfun(@(x) strcmpi(x, "i2c"), ar.libraries()), 1)))
 assert(!isempty(find(cellfun(@(x) strcmpi(x, "servo"), ar.libraries()), 1)))
 assert(!isempty(find(cellfun(@(x) strcmpi(x, "shiftregister"), ar.libraries()), 1)))
 assert(!isempty(find(cellfun(@(x) strcmpi(x, "rotaryencoder"), ar.libraries()), 1)))
!!!!! test failed
assert (!isempty (find (cellfun (@(x)strcmpi (x, "rotaryencoder"), ar.libraries ()), 1))) failed
shared variables 
    arduinos =
    {
      [1,1] =

        scalar structure containing the fields:

          port = /dev/ttyUSB0
          board = uno

    }
octave:3> a = arduino ("/dev/ttyUSB0","","Debug", 1, "Baudrate", 9600)
>> 165 0 1 0 
<< 165 0 1 7 
<< 30 149 15 0 50 5 0 
>> 165 0 8 1 0 
<< 165 0 8 5 
<< 0 67 111 114 101 
>> 165 0 8 1 1 
<< 165 0 8 4 
<< 1 73 50 67 
>> 165 0 8 1 2 
<< 165 0 8 4 
<< 2 83 80 73 
>> 165 0 8 1 3 
<< 165 0 8 6 
<< 3 83 101 114 118 111 
>> 165 0 8 1 4 
<< 165 0 8 14 
<< 4 83 104 105 102 116 82 101 103 105 115 116 101 114 
a =

  arduino object with fields of: 
            port = /dev/ttyUSB0
           board = uno
       libraries = {
              i2c
              spi
              servo
              shiftregister
        }
        availablepins = {
              d0 - d13
              a0 - a5
        }
       config = 
    board = uno
    baudrate = 9600
    mcu = atmega328p
    voltref = 5
    libs =
    {
      [1,1] =

        scalar structure containing the fields:

          id = 0
          name = core

      [1,2] =

        scalar structure containing the fields:

          id = 1
          name = i2c

      [1,3] =

        scalar structure containing the fields:

          id = 2
          name = spi

      [1,4] =

        scalar structure containing the fields:

          id = 3
          name = servo

      [1,5] =

        scalar structure containing the fields:

          id = 4
          name = shiftregister

    }

    port = /dev/ttyUSB0
    description = Arduino Uno R3 Board
    pins =
    {
      [1,1] =

        scalar structure containing the fields:

          name = d0
          id = 0
          modes =
          {
            [1,1] = digital
            [1,2] = uart
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,2] =

        scalar structure containing the fields:

          name = d1
          id = 1
          modes =
          {
            [1,1] = digital
            [1,2] = uart
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,3] =

        scalar structure containing the fields:

          name = d2
          id = 2
          modes =
          {
            [1,1] = digital
            [1,2] = interrupt
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,4] =

        scalar structure containing the fields:

          name = d3
          id = 3
          modes =
          {
            [1,1] = digital
            [1,2] = pwm
            [1,3] = interrupt
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,5] =

        scalar structure containing the fields:

          name = d4
          id = 4
          modes =
          {
            [1,1] = digital
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,6] =

        scalar structure containing the fields:

          name = d5
          id = 5
          modes =
          {
            [1,1] = digital
            [1,2] = pwm
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,7] =

        scalar structure containing the fields:

          name = d6
          id = 6
          modes =
          {
            [1,1] = digital
            [1,2] = pwm
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,8] =

        scalar structure containing the fields:

          name = d7
          id = 7
          modes =
          {
            [1,1] = digital
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,9] =

        scalar structure containing the fields:

          name = d8
          id = 8
          modes =
          {
            [1,1] = digital
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,10] =

        scalar structure containing the fields:

          name = d9
          id = 9
          modes =
          {
            [1,1] = digital
            [1,2] = pwm
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,11] =

        scalar structure containing the fields:

          name = d10
          id = 10
          modes =
          {
            [1,1] = digital
            [1,2] = pwm
            [1,3] = spi0_ss
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,12] =

        scalar structure containing the fields:

          name = d11
          id = 11
          modes =
          {
            [1,1] = digital
            [1,2] = pwm
            [1,3] = spi0_mosi
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,13] =

        scalar structure containing the fields:

          name = d12
          id = 12
          modes =
          {
            [1,1] = digital
            [1,2] = pwm
            [1,3] = spi0_miso
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,14] =

        scalar structure containing the fields:

          name = d13
          id = 13
          modes =
          {
            [1,1] = digital
            [1,2] = pwm
            [1,3] = spi0_sck
            [1,4] = led
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,15] =

        scalar structure containing the fields:

          name = a0
          id = 14
          modes =
          {
            [1,1] = digital
            [1,2] = analog
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,16] =

        scalar structure containing the fields:

          name = a1
          id = 15
          modes =
          {
            [1,1] = digital
            [1,2] = analog
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,17] =

        scalar structure containing the fields:

          name = a2
          id = 16
          modes =
          {
            [1,1] = digital
            [1,2] = analog
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,18] =

        scalar structure containing the fields:

          name = a3
          id = 17
          modes =
          {
            [1,1] = digital
            [1,2] = analog
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,19] =

        scalar structure containing the fields:

          name = a4
          id = 18
          modes =
          {
            [1,1] = digital
            [1,2] = analog
            [1,3] = i2c_sda
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

      [1,20] =

        scalar structure containing the fields:

          name = a5
          id = 19
          modes =
          {
            [1,1] = digital
            [1,2] = analog
            [1,3] = i2c_scl
          }

          owner = 
          mode = unset
          altnames = {}(0x0)

    }

    flags = 0

Dmitri.

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.