Arduberry Sketch stops working after some time


#1

Arduberry losses it’s sketch or miss-behaving after a day of running. It’s stop responding to my serial comm port communication program. The only way I am fixing this issue is by re-uploading my sketch again.

What causes the comm port failure? How to debug this issue?


#2

Hi,
Can you post the sketch here so that we can have a look. Also, can you tell us more how you are using the Serial port. Is it connected to a sensor or are you using a Serial Port monitor, and if so what .

-Karan


#3
#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {

  Serial.begin(9600);

    pinMode(1,INPUT);
    mySwitch.enableReceive(1);
  // Transmitter is connected to Arduino Pin #10
    mySwitch.enableTransmit(10);

  // Optional set pulse length.

  // Optional set protocol (default is 1, will work for most outlets)
  // mySwitch.setProtocol(2);

  // Optional set number of transmission repetitions.
   //mySwitch.setRepeatTransmit(15);

}

void loop() {

//  Serial.println("hello");
 // delay(1000);

if (mySwitch.available()) {

    int value = mySwitch.getReceivedValue();

    if (value == 0) {
      Serial.println("Unknown encoding");
    } else {

      Serial.println( mySwitch.getReceivedValue() );
      Serial.println( mySwitch.getReceivedDelay());
      Serial.println( mySwitch.getReceivedBitlength() );

    }

   mySwitch.resetAvailable();
  }

  if(Serial.available()){
    long rfCmd;
    int pulse;
    int bits;
    rfCmd=Serial.parseInt();
    pulse = Serial.parseInt();
    bits = Serial.parseInt();
    sendRCSwitch(pulse,rfCmd,bits);
    Serial.println(rfCmd);

  }

//  delay(1000);

}

void sendRCSwitch(int pulse, long rfCmd,int bits){

  mySwitch.setPulseLength(pulse);
  delay(100);
  mySwitch.send(rfCmd,bits);
  delay(300);
  mySwitch.send(rfCmd,bits);

}


I am using NoneJS to read the serial port data from the other end.


#4

Hi,
The Sketch looks fine. I don’t know exactly what’s going wrong. Can you double-check if serial login and serial boot messages are disabled: http://www.raspberrypi-spy.co.uk/2013/12/free-your-raspberry-pi-serial-port/

-Karan


#5

I checked serial login and serial boot messages are disabled.

Power cycle and reboot doesn’t fix the problem. Only reloading the arduino sketch fixes it. Does it give us any clue ?


#6

Sorry, but I cannot think of anything. Doesn’t resetting the Arduberry help? Does it work fine on a normal Arduino Uno?

-Karan


#7

I did some digging around. I found the arduino script fails when serial command is sent back to back without any delay. May be I should add delay/sleep in arduino script?


#8

I think adding a delay might help. Usually, it takes sometime for the sensor to respond to the command and maybe when it’s processing the previous command, a new command comes and the sensor overlooks it, which might be causing the problem.

Do try the delay and let us know if it works.

-Karan