**Project Link:** https://wokwi.com/projects/333785509332517459?gh=1
Error message: DEFINE_PIN(RX);
^
int
/sketch/gps-fake.chip.c:12:12: error: a parameter list without types is only allowed in a function definition
DEFINE_PIN(RX);
^
/sketch/gps-fake.chip.c:13:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
DEFINE_PIN(TX);
^
int
/sketch/gps-fake.chip.c:13:12: error: a parameter list without types is only allowed in a function definition
DEFINE_PIN(TX);
^
/sketch/gps-fake.chip.c:14:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
DEFINE_PIN(VCC);
^
int
/sketch/gps-fake.chip.c:14:12: error: a parameter list without types is only allowed in a function definition
DEFINE_PIN(VCC);
^
/sketch/gps-fake.chip.c:15:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
DEFINE_PIN(GND);
^
int
/sketch/gps-fake.chip.c:15:12: error: a parameter list without types is only allowed in a function definition
DEFINE_PIN(GND);
^
/sketch/gps-fake.chip.c:112:13: error: parameter 'chip_timer_event' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
void EXPORT(chip_timer_event)(chip_state_t *chip, uint32_t timer_id) {
^
/sketch/gps-fake.chip.c:112:12: error: function cannot return function type 'void (chip_state_t *, uint32_t)' (aka 'void (chip_state_t *, unsigned int)')
void EXPORT(chip_timer_event)(chip_state_t *chip, uint32_t timer_id) {
^
/sketch/gps-fake.chip.c:113:7: error: use of undeclared identifier 'timer_id'
if (timer_id == chip->tx_timer) {
^
/sketch/gps-fake.chip.c:113:19: error: use of undeclared identifier 'chip'
if (timer_id == chip->tx_timer) {
^
/sketch/gps-fake.chip.c:114:39: error: use of undeclared identifier 'chip'
const char *message = gps_tx_data[chip->gps_tx_index++];
^
/sketch/gps-fake.chip.c:115:38: error: call to undeclared library function 'strlen' with type 'unsigned long (const char *)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
uart_write(chip->uart0, message, strlen(message));
^
/sketch/gps-fake.chip.c:115:38: note: include the header <string.h> or explicitly provide a declaration for 'strlen'
/sketch/gps-fake.chip.c:115:16: error: use of undeclared identifier 'chip'
uart_write(chip->uart0, message, strlen(message));
^
/sketch/gps-fake.chip.c:116:9: error: use of undeclared identifier 'chip'
if (chip->gps_tx_index >= LEN(gps_tx_data)) {
^
/sketch/gps-fake.chip.c:117:7: error: use of undeclared identifier 'chip'
chip->gps_tx_index = 0;
^
/sketch/gps-fake.chip.c:112:6: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
void EXPORT(chip_timer_event)(chip_state_t *chip, uint32_t timer_id) {
^
/sketch/gps-fake.chip.c:122:7: error: conflicting types for 'chip_init'
void* chip_init(void) {
^
/src/wokwi-api.h:45:54: note: previous declaration is here
extern __attribute__((export_name("chipInit"))) void chip_init(void);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
Error: Process exited with 1/*
GPS Fake using custom chip
by Anderson Costa
GPS NMEA 0183 Messaging Protocol 101
https://docs.arduino.cc/learn/communication/gps-nmea-data-101
NMEA Generator
https://www.nmeagen.org/
*/
#include "NMEA.h"
#define LEN(arr) ((int)(sizeof(arr) / sizeof(arr)[0]))
union {
char bytes[4];
float valor;
} velocidadeGPS;
float latitude;
float longitude;
// Creates a GPS data connection with sentence type GPRMC
NMEA gps(GPRMC);
void setup() {
Serial.begin(9600);
Serial1.begin(4800); // Serial1 is connected to the custom chip
Serial.println("Data received from GPS Fake:");
}
void loop() {
// Waits for serial port data
while (Serial1.available()) {
// Receives data from GPS serial port
char serialData = Serial1.read();
Serial.print(serialData);
// Checks if the GPS sentence is valid
if (gps.decode(serialData)) {
// Checks if GPS status is 'A'
if (gps.gprmc_status() == 'A') {
// Receives GPS speed in km/h
velocidadeGPS.valor = gps.gprmc_speed(KMPH);
} else {
velocidadeGPS.valor = 0;
}
latitude = gps.gprmc_latitude();
longitude = gps.gprmc_longitude();
// Add line break
Serial.println();
Serial.println();
// Show Latitude
Serial.print(" Latitude: ");
Serial.println(latitude, 8);
// Show Longitude
Serial.print("Longitude: ");
Serial.println(longitude, 8);
// Show Speed in km/h
Serial.print(" Speed: ");
Serial.print(velocidadeGPS.valor);
Serial.println(" Km/h");
// Converts Geographic Coordinates to Cartesian Plane
convertCoordinatesToCartesian(latitude, longitude);
}
}
}
void convertCoordinatesToCartesian(float latitude, float longitude) {
// Convert from Degrees to Radians
float latRadius = latitude * (PI) / 180;
float lonRadius = longitude * (PI) / 180;
int earthRadius = 6371; // Radius in km
float posX = earthRadius * cos(latRadius) * cos(lonRadius);
float posY = earthRadius * cos(latRadius) * sin(lonRadius);
Serial.print(" X: ");
Serial.println(posX);
Serial.print(" Y: ");
Serial.println(posY);
}