I’m trying to set up a communication from Medusa mini to a Gadgeteer Board via RS232 but I have problems to write to RS232 on the Medusa Mini (Arduino newbie).
#include <Wire.h>
#include <SPI.h>
#include <Gadgeteering.h>
#include <Mainboards/FEZMedusaMini.h>
#include <Modules/RS232.h>
using namespace gadgeteering;
using namespace gadgeteering::mainboards;
using namespace gadgeteering::modules;
fez_medusa_mini board;
rs_232* my_Rs232;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
my_Rs232 = new rs_232(2);
my_Rs232.write("Hello World");
}
I get the the errormessage:
Arduino: 1.6.5 (Windows 8.1), Platine: “FEZ Medusa”
Medusa_Mini_RS232_Test.ino: In function ‘void setup()’:
Medusa_Mini_RS232_Test:39: error: request for member ‘write’ in ‘my_Rs232’, which is of pointer type ‘gadgeteering::modules::rs_232*’ (maybe you meant to use ‘->’ ?)
request for member ‘write’ in ‘my_Rs232’, which is of pointer type ‘gadgeteering::modules::rs_232*’ (maybe you meant to use ‘->’ ?)
How can the string be sent?
Another question: how can the RS232 module be configurated different from the defaults:
#pragma once
#include "Types.h"
#include "Socket.h"
#include "SoftwareI2C.h"
namespace gadgeteering
{
namespace devices
{
class serial
{
serial_channel channel;
public:
serial_configuration config;
serial(const socket& sock, serial_configuration configuration);
serial(serial_channel channel, serial_configuration configuration);
~serial();
void change_config(serial_configuration configuration);
void write(const unsigned char* buffer, unsigned int length);
void write(const char* buffer, unsigned int length = 0);
unsigned int read(unsigned char* buffer, unsigned int length);
unsigned int available();
};
}
}
#pragma once
#ifndef NULL
#define NULL 0
#endif
namespace gadgeteering
{
typedef unsigned char io_mode;
typedef unsigned char resistor_mode;
typedef unsigned char spi_channel;
typedef unsigned char i2c_channel;
typedef unsigned char serial_channel;
typedef unsigned char analog_channel;
typedef unsigned char analog_out_channel;
typedef unsigned char pwm_channel;
typedef unsigned char error_type;
typedef unsigned char cpu_pin;
typedef unsigned char socket_pin_number;
static const cpu_pin UNCONNECTED_PIN = 0xFF;
/// @ brief Struct containing possible Serial (UART) channels
struct serial_channels
{
static const serial_channel SERIAL_0 = 0;
static const serial_channel SERIAL_1 = 1;
static const serial_channel SERIAL_2 = 2;
static const serial_channel SERIAL_3 = 3;
static const serial_channel SERIAL_4 = 4;
static const serial_channel SERIAL_5 = 5;
static const serial_channel NONE = 0xFF;
};
/// @ brief Contains configuration for a Serial (UART) transaction
struct serial_configuration
{
typedef unsigned char parity;
typedef unsigned char stop_bit;
/// The speed at which data will be sent (in bits-per-second)
unsigned int baud_rate;
/// The parity that will be used to detect erroneous communications
parity data_parity;
/// The number of bits that will be used to detect and signify the end of a character
stop_bit stop_bits;
/// The number of data bits in each character
unsigned char data_bits;
/// @ brief Contains definitions of the available parities
struct parities
{
/// Arrange transmitted data with an even parity
static const parity EVEN = 0;
/// Arrange transmitted data with an odd parity
static const parity ODD = 1;
/// Arrange transmitted data with parity bit on the mark signal condition
static const parity MARK = 2;
/// Arrange transmitted data with parity bit on the space signal condition
static const parity SPACE = 3;
/// Arrange transmitted data with no parity
static const parity NONE = 4;
};
/// @ brief Contains definitions of the available stop bit conditions
struct stop_bits
{
/// Uses one bit to signify the end of a character. This is the default for most electronic devices.
static const stop_bit ONE = 1;
/// Uses one and a half bits to signify the end of a character.
static const stop_bit ONE_POINT_FIVE = 2;
/// Uses two bits to signify the end of a character.
static const stop_bit TWO = 3;
};
/// @ brief The serial_configuration constructor
/// @ param baud_rate The speed at which data will be sent (in bits-per-second)
/// @ param parity The parity that will be used to detect erroneous communications (Default: none)
/// @ param stop_bits The number of bits that will be used to detect and signify the end of a character
/// @ param data_bits The number of data bits in each character
serial_configuration(unsigned int baud_rate = 9600, parity parity = parities::NONE, stop_bit stop_bits = stop_bits::ONE, unsigned char data_bits = 8);
};
}
}
@ John - yes, I know. Sorry, if I was not clear enough.
What I do not know is, how to write the arguments without getting an error message of the compiler.