austinbv / dino

Dino is a ruby gem that helps you bootstrap prototyping with an Arduino
MIT License
388 stars 84 forks source link

Leonardo board error #65

Closed justinledwards closed 10 years ago

justinledwards commented 10 years ago
dino_serial:12: error: conversion from 'Serial_' to non-scalar type 'HardwareSerial' requested

I just got in my leonardo boards and wanted to see if dino worked well on them. I was able to change serial to Serial1 and get that error to go away, but I still get an error when trying to connect to the board.

HardwareSerial serial = Serial1;
irb
2.0.0-p195 :001 > require 'dino'
 => true 
2.0.0-p195 :002 > board = Dino::Board.new(Dino::TxRx::Serial.new)
Dino::BoardNotFound: Dino::BoardNotFound
    from ~/.rvm/gems/ruby-2.0.0-p195/gems/dino-0.12.0/lib/dino/tx_rx/base.rb:46:in `handshake'
    from ~/.rvm/gems/ruby-2.0.0-p195/gems/dino-0.12.0/lib/dino/board.rb:11:in `initialize'
    from (irb):2:in `new'
    from (irb):2
    from ~/.rvm/rubies/ruby-2.0.0-p195/bin/irb:16:in `<main>'
vickash commented 10 years ago

Looks like the #ifdef statement for detecting different serial interfaces needs to be refined. In the meantime can you change Serial on https://github.com/austinbv/dino/blob/0.12.0-wip/src/dino_serial.ino#L20 to serial and see if that works?

justinledwards commented 10 years ago

It didn't do anything new. Should I compile it with debug and open the monitor and do anything? It oddly looks to be connected, I have to kill irb to be able to communicate with the IDE after trying to connect.

vickash commented 10 years ago

It should work once serial ends up pointing to Serial1 for the Leonardo. You can open the monitor in the Arduino IDE and just type 99. If it responds, no reason it shouldn't work with ruby.

On Tuesday, October 15, 2013 at 9:17 PM, Justin Edwards wrote:

It didn't do anything new. Should I compile it with debug and open the monitor and do anything? It oddly looks to be connected, I have to kill irb to be able to communicate with the IDE after trying to connect.

— Reply to this email directly or view it on GitHub (https://github.com/austinbv/dino/issues/65#issuecomment-26386192).

justinledwards commented 10 years ago

It blinks like it acknowledges something, but there isn't any output. I actually checked around online a bit and looks like I need to upgrade my IDE (1.5.2) there were some fixes in 1.5.4. I'm going to try a few things. I couldn't get any output from even basic serial examples.

justinledwards commented 10 years ago
Command - 99
Pin - 
Value - 
Responded with - 

I was able to get it working by removing the checks at the beginning including hardwarserial and then changing all lowercase serial to Serial

#include "Dino.h"
#include <Servo.h>
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
#include "DHT.h"
Dino dino;

// Use the native Serial port on the Arduino Due

// Dino.h doesn't handle TXRX. Setup a function to tell it to write to Serial.
void writeResponse(char *response) { Serial.print(response); }
void (*writeCallback)(char *str) = writeResponse;

void setup() {
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  dino.setupWrite(writeCallback);
}

void loop() {
  while(Serial.available() > 0) dino.parse(Serial.read());
  dino.updateListeners();
  Serial.flush();
}