Uploading firmware


#1

I've tried to add a code ( a .cpp and a .h) for a new device but now when I charge the firmware it say that have compiled and upload correctly but I don't have the control of the robot, nor the left energy and that sort of things.... do you know why can I have this issue?

staging: build dir is /tmp/tmp.ZNjovJnONO
staged src in to build folder
src/OpenROV.ino
Searching for Arduino lib version file (version.txt) ... /usr/share/arduino/lib/version.txt
Detecting Arduino software version ... 1.0.5 (1.0.5)
Scanning dependencies of src
Scanning dependencies of arduino
Scanning dependencies of EEPROM
Scanning dependencies of SPI
Scanning dependencies of Wire
src/Thrusters2X1.cpp
src/MinIMU9.cpp
src/inv_mpu_dmp_motion_driver.cpp
src/MinIMU_L3G.cpp
src/Timer.cpp
src/Lights.cpp
src/Pin.cpp
src/inv_mpu.cpp
src/Pilot.cpp
src/controllerboard25.cpp
src/Motors.cpp
src/MinIMU_Vector.cpp
src/Command.cpp
src/MinIMU_Output.cpp
src/MPU9150Lib.cpp
src/MinIMU9AHRS.cpp
src/MS5803_14BA.cpp
src/ArduSlave.cpp
src/CalLib.cpp
src/I2Cdev.cpp
src/MPUQuaternion.cpp
src/Device.cpp
src/MinIMU_I2C.cpp
src/MPU9150.cpp
src/MinIMU_DCM.cpp
src/MinIMU_Compass.cpp
src/CalibrationLaser.cpp
src/Cape.cpp
src/MinIMU_matrix.cpp
src/MinIMU_LSM303.cpp
src/MPUVector3.cpp
src/openrov_servo.cpp
src/Settings.cpp
src/CameraMount.cpp
src/FreeMem.cpp
src/OpenROV.cpp
EEPROM/EEPROM.cpp
Linking libEEPROM.a
SPI/SPI.cpp
Linking libSPI.a
Wire/utility/twi.c
Wire/Wire.cpp
Linking libWire.a
arduino/wiring_digital.c
arduino/wiring_pulse.c
arduino/wiring.c
arduino/wiring_analog.c
arduino/avr-libc/realloc.c
arduino/avr-libc/malloc.c
arduino/WInterrupts.c
arduino/wiring_shift.c
arduino/Stream.cpp
arduino/IPAddress.cpp
arduino/WMath.cpp
arduino/HardwareSerial.cpp
arduino/Print.cpp
arduino/HID.cpp
arduino/main.cpp
arduino/WString.cpp
arduino/Tone.cpp
arduino/CDC.cpp
arduino/USBCore.cpp
arduino/new.cpp
Linking libarduino.a
Linking firmware.elf
Converting to firmware.hex
Searching for Board description file (boards.txt) ... /usr/share/arduino/hardware/arduino/boards.txt
Searching for Arduino lib version file (version.txt) ... /usr/share/arduino/lib/version.txt
Detecting Arduino software version ... 1.0.5 (1.0.5)
Searching for Arduino core library ... /usr/share/arduino/hardware/arduino/cores/arduino
Searching for Arduino standard libraries ... /usr/share/arduino/libraries
Searching for Arduino variants directory ... /usr/share/arduino/hardware/arduino/variants
Searching for make ... /usr/share/arduino/hardware/tools/avr/bin/make
Searching for avr-gcc ... /usr/share/arduino/hardware/tools/avr/bin/avr-gcc
Searching for avr-g++ ... /usr/share/arduino/hardware/tools/avr/bin/avr-g++
Searching for avr-ar ... /usr/share/arduino/hardware/tools/avr/bin/avr-ar
Searching for avr-objcopy ... /usr/share/arduino/hardware/tools/avr/bin/avr-objcopy
Setting up uploader
Initiating arduino reset on pin 30

avrdude: Version 6.1-svn-20130917, compiled on Dec 25 2013 at 20:39:41
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "/etc/avrdude.conf"
User configuration file is "/root/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/spidev1.0
Using Programmer : linuxspi
AVR Part : ATmega2560
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 10 8 0 no 4096 8 0 9000 9000 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
flash 65 10 256 0 yes 262144 256 1024 4500 4500 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : linuxspi
Description : Use Linux SPI device in /dev/spidev*

avrdude: AVR device initialized and ready to accept instructions
Arduino reset set high, Arduino enabled.

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.


avrdude done. Thank you.

upload failed, trying again.
Initiating arduino reset on pin 30

avrdude: Version 6.1-svn-20130917, compiled on Dec 25 2013 at 20:39:41
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "/etc/avrdude.conf"
Arduino reset set high, Arduino enabled.
User configuration file is "/root/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/spidev1.0
Using Programmer : linuxspi
AVR Part : ATmega2560
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 10 8 0 no 4096 8 0 9000 9000 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
flash 65 10 256 0 yes 262144 256 1024 4500 4500 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : linuxspi
Description : Use Linux SPI device in /dev/spidev*

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9801
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file ".build/mega2560/firmware.hex"
avrdude: input file .build/mega2560/firmware.hex auto detected as Intel Hex
avrdude: writing flash (44464 bytes):

Writing | ################################################## | 100% 7.77s

avrdude: 44464 bytes of flash written
avrdude: verifying flash memory against .build/mega2560/firmware.hex:
avrdude: load data flash data from input file .build/mega2560/firmware.hex:
avrdude: input file .build/mega2560/firmware.hex auto detected as Intel Hex
avrdude: input file .build/mega2560/firmware.hex contains 44464 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 13.46s

avrdude: verifying ...
avrdude: 44464 bytes of flash verified

avrdude done. Thank you.

upload successfull!


#2

Here are the codes if you want to check them:

ArduSlave.cpp

#include <AltSoftSerial.h> //Include the software serial library
#include <Wire.h>

const byte i2c_address=0x77;
AltSoftSerial altSerial; //Name the software serial library altSerial (this cannot be omitted)

int s0 = 7; //Arduino pin 7 to control pin S0
int s1 = 6; //Arduino pin 6 to control pin S1

char sensordata[30]; //A 30 byte character array to hold incoming data from the sensors
byte sensor_bytes_received=0; //We need to know how many characters bytes have been received

struct data
{
struct {
float ec;
float tds;
float sal;
float sg;
}
conductivity;
float pH;
float DO;
float ORP;
float temperature;
};

const int data_size=sizeof(data);

const int waiting_time = 1000;

data data_from_sensors = {
{
0, 0, 0, 0 }
,
0,
0,
0,
0
};

void setup() {
pinMode(s1, OUTPUT); //Set the digital pin as output.
pinMode(s0, OUTPUT); //Set the digital pin as output.
pinMode(2, OUTPUT); //Set pin 2 as an output
Serial.begin(38400); //Set the hardware serial port to 38400
altSerial.begin(38400); //Set the soft serial port to 38400
Wire.begin(i2c_address);
Wire.onRequest(requestEvent);
}





void loop(){
data_from_sensors.temperature = read_temp();
open_channel(0);
Serial.print("Conductivity==>");
altSerial.print("R\r");
leeBuffer();
const char *delimitador=",";
data_from_sensors.conductivity.ec=atof(strtok(sensordata,delimitador));
data_from_sensors.conductivity.tds=atof(strtok(NULL,delimitador));
data_from_sensors.conductivity.sal=atof(strtok(NULL,delimitador));
data_from_sensors.conductivity.sg=atof(strtok(NULL,delimitador));

open_channel(1);
Serial.print("pH==>");
altSerial.print("R\r");
leeBuffer();
data_from_sensors.pH=atof(sensordata);

open_channel(2);
Serial.print("DO==>");
altSerial.print("R\r");
leeBuffer();
data_from_sensors.DO=atof(sensordata);

open_channel(3);
Serial.print("ORP==>");
altSerial.print("R\r");
leeBuffer();
data_from_sensors.ORP=atof(sensordata);

Serial.println();
Serial.println(" DATA IN STRUCTURE ");
Serial.println("-------------------");
Serial.print("Conductividad==> EC: ");
Serial.print(data_from_sensors.conductivity.ec);
Serial.print(", TDS: ");
Serial.print(data_from_sensors.conductivity.tds);
Serial.print(", SAL: ");
Serial.print(data_from_sensors.conductivity.sal);
Serial.print(", SG: ");
Serial.println(data_from_sensors.conductivity.sg);

Serial.print("pH==> ");
Serial.println(data_from_sensors.pH);
Serial.print("DO==> ");
Serial.println(data_from_sensors.DO);
Serial.print("ORP==> ");
Serial.println(data_from_sensors.ORP);

// resto de datos de la estructura
Serial.print("Temperatura==> ");
Serial.println(data_from_sensors.temperature);

Serial.println("-------------------");
Serial.println(" DATA IN STRUCTURE END ");
Serial.println();
delay(5000);
}

void leeBuffer(){
delay(waiting_time);
if(altSerial.available() > 0){ //If data has been transmitted from an Atlas Scientific device
sensor_bytes_received=altSerial.readBytesUntil(13,sensordata,30); //we read the data sent from the Atlas Scientific device until we see a <CR>. We also count how many character have been received
sensordata[sensor_bytes_received]=0; //we add a 0 to the spot in the array just after the last character we received. This will stop us from transmitting incorrect data that may have been left in the buffer
Serial.println(sensordata);
}
}

void open_channel(int channel){ //This function controls what UART port is opened.

if (channel & 1){
digitalWrite(s0, HIGH);
}
else {
digitalWrite(s0,LOW);
}
if (channel & 2){
digitalWrite(s1, HIGH);
}
else {
digitalWrite(s1,LOW);
}
delay(100);
int bytesResiduo=altSerial.available();
if(bytesResiduo > 0){
sensor_bytes_received=altSerial.readBytes(sensordata, bytesResiduo);
sensordata[bytesResiduo]=0;
Serial.print("ATENCION: DATOS NO LEIDOS: ");
Serial.println(sensordata);
}
}

float read_temp(void){ //the read temperature function
float v_out; //voltage output from temp sensor
float temp; //the final temperature is stored here
digitalWrite(A0, LOW); //set pull-up on analog pin
digitalWrite(2, HIGH); //set pin 2 high, this will turn on temp sensor
delay(2); //wait 2 ms for temp to stabilize
v_out = analogRead(0); //read the input pin
digitalWrite(2, LOW); //set pin 2 low, this will turn off temp sensor
v_out*=.0048; //convert ADC points to volts (we are using .0048 because this device is running at 5 volts)
v_out*=1000; //convert volts to millivolts
temp= 0.0512 * v_out -20.5128; //the equation from millivolts to temperature
return temp; //send back the temp
}

void requestEvent(){
byte *pDatos= (byte *) &data_from_sensors;
Wire.write(pDatos, data_size);
}

Arduslave.h

#ifndef __ArduSlave_H_
#define __ArduSlave_H_
#include <Arduino.h>
#include "Device.h"

struct data
{
struct {
float ec;
float tds;
float sal;
float sg;
}
conductivity;
float pH;
float DO;
float ORP;
float temperature;
};
const int data_size=sizeof(data);

const unsigned arduslave_timeout=100;

class ArduSlave : public Device {
public:
ArduSlave():Device(){};
void device_setup();
void device_loop(Command cmd);
};
#endif

arduslave.cpp:

#include "AConfig.h"
#if(HAS_ARDUSLAVE)

#include "ArduSlave.h"
// #include "Settings.h"
//#include "Timer.h"
#include <Wire.h>

/*
Sketch to read a MS5803-14BA pressure sensor, written from scratch.
Will output data to the serial console.

Written by Walt Holm
Initial revision 10 Oct 2013
Rev 1 12 Oct 2013 -- Implements 2nd order temperature compensation
*/



const int DevAddress = ARDUSLAVE_I2CADDRESS; // 7-bit I2C address of the MS5803

void ArduSlave::device_setup(){
//Settings::capability_bitarray |= (1 DEAPTH_CAPABLE);

Serial.println("ArduSlave setup.");
Wire.begin();
delay(10);
}

void ArduSlave::device_loop(Command command){
Wire.requestFrom(DevAddress, 32);
data data_from_arduslave;

unsigned int millis_start = millis();
byte *pBdata = (byte *) &data_from_arduslave;
for (int i=0; i<data_size; i++){
if (Wire.available()){
pBdata[i]=Wire.read();
}
else {
if (((unsigned int)millis() - millis_start) > arduslave_timeout) {
Serial.println("log:Failed to read ArduSlave from I2C");
return;
}
}
}
Serial.println();
Serial.println(" DATA IN ARDUSLAVE ");
Serial.println();
Serial.print("Conductividad==> EC: ");
Serial.print(data_from_arduslave.conductivity.ec);
Serial.print(", TDS: ");
Serial.print(data_from_arduslave.conductivity.tds);
Serial.print(", SAL: ");
Serial.print(data_from_arduslave.conductivity.sal);
Serial.print(", SG: ");
Serial.println(data_from_arduslave.conductivity.sg);

Serial.print("pH==> ");
Serial.println(data_from_arduslave.pH);
Serial.print("DO==> ");
Serial.println(data_from_arduslave.DO);
Serial.print("ORP==> ");
Serial.println(data_from_arduslave.ORP);

// resto de datos de la estructura
Serial.print("Temperatura==> ");
Serial.println(data_from_arduslave.temperature);

Serial.println();
Serial.println(" DATA IN ARDUSLAVE END ");
Serial.println();
}
#endif

And here is what I've change in openrov.ino and Aconfig.h

  • Openrov.ino: just before the line Command cmd#if(HAS_ARDUSLAVE)
    #include "ArduSlave.h"
    ArduSlave kit_sensores;
    #endif
  • AConfig.h: just after #define MPU9150_EEPROM_START 2

#define HAS_ARDUSLAVE (1)
#define ARDUSLAVE_I2CADDRESS 0x77


#3

Hello,

I have a problem with my code, finally I manage to compile it (there where several sintax errors) and now, when I upload the firmware, I lose connection with the ROV, I would like to know if someone has a clue of why is this happening.

Thank you very much!