0

I'm getting an error when trying to run some code on my raspberry pi. Here is the source code:

/*
SimpleReceive
This sketch displays text strings received using VirtualWire
Connect the Receiver data pin to Arduino pin 11
*/

#include "VirtualWire.h"
#include "wiringSerial.h"
#include <wiringPi.h>
#include <string.h>
#include <stdio.h>
#include <time.h>

const char message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
unsigned char messageLength = VW_MAX_MESSAGE_LEN; // the size of the message
int fd;

wiringPiSetup();
fd = serialOpen("/dev/ttyAMA0", 9600);

void send (char *message)
{
vw_send((uint8_t *)message, strlen(message));
vw_wait_tx(); // Wait until the whole message is gone
}

void setup()
{
serialOpen("/dev/ttyAMA0", 9600);
serialPrintf(fd, "Device is ready");
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver
}
void loop()
{
send("Hello there");
//delay(1000);
if (vw_get_message(message, &messageLength)) // Non-blocking
{
serialPrintf(fd, "Received: ");
for (int i = 0; i < messageLength; i++)
{
serialPrintf(fd, message[i]);
}
serialPuts(fd, "test");
}
}

I'm getting this error:

receiver.c:37:6: error: initializer element is not constant
 fd = serialOpen("/dev/ttyAMA0", 9600);

Any ideas what they mean?

Thanks!

ajnauleau
  • 109
  • 1

0 Answers0