Hello,
I'm quite new to arduino and programming in general. My problem however is quite strange, since it seems others don't have a problem with this particular class. The class im talking about is SendOnlySoftwareSerial. I downloaded the class from the MultiWii project website and tried to use it in my own project, but somehow it isn't recognized by the aruino ide (Linux, v1.0.5). I created a test project, and stripped the class to bare minimum, but the problem remains. Below three files are all in a 'test' directory:
SendOnlySoftwareSerial.h
#ifndef SendOnlySoftwareSerial_h
#define SendOnlySoftwareSerial_h
#include "Arduino.h"
#include <inttypes.h>
#include <Stream.h>
class SendOnlySoftwareSerial : public Stream
{
private:
uint16_t _tx_delay;
uint16_t _inverse_logic;
uint16_t _errors_ok;
// private methods
void setTX(uint8_t transmitPin);
public:
// public methods
SendOnlySoftwareSerial(uint8_t transmitPin, bool inverse_logic = false, bool errors_ok = false);
~SendOnlySoftwareSerial();
void begin(long speed);
void end();
int peek();
size_t write(uint8_t b);
virtual int read();
virtual int available();
virtual void flush();
};
#endif // SendOnlySoftwareSerial_h
SendOnlySoftwareSerial.cpp
#include <Stream.h>
#include <avr/pgmspace.h>
#include "SendOnlySoftwareSerial.h"
SendOnlySoftwareSerial::SendOnlySoftwareSerial(uint8_t transmitPin, bool inverse_logic /* = false */, bool errors_ok /* = false */) :
_tx_delay(0),
_inverse_logic(inverse_logic),
_errors_ok(errors_ok)
{
setTX(transmitPin);
}
SendOnlySoftwareSerial::~SendOnlySoftwareSerial()
{
end();
}
void SendOnlySoftwareSerial::setTX(uint8_t tx)
{
pinMode(tx, OUTPUT);
digitalWrite(tx, HIGH);
}
void SendOnlySoftwareSerial::begin(long speed)
{
_tx_delay = 200;
}
void SendOnlySoftwareSerial::end()
{
}
size_t SendOnlySoftwareSerial::write(uint8_t b)
{
return 0;
}
int SendOnlySoftwareSerial::available()
{
return 0;
}
int SendOnlySoftwareSerial::read()
{
return -1;
}
void SendOnlySoftwareSerial::flush()
{
return;
}
int SendOnlySoftwareSerial::peek()
{
return -1;
}
test.ino
#include "SendOnlySoftwareSerial.h"
#define TELEMETRY_FRSKY_SOFTSERIAL_PIN 2
SendOnlySoftwareSerial sserial(TELEMETRY_FRSKY_SOFTSERIAL_PIN, true, true);
sserial.begin(9600);
This results in:
Error compiling.
test.ino:7:1: error: ‘sserial’ does not name a type
The same error comes, if I try to call the public 'write' method of the class, but doesn't come I just call the constructor (which does call the private 'setTX' method). Is there something obvious I'm missing here?
I'd appreciate any help... tia, juhis