Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: error in library file on: November 13, 2012, 03:54:38 am
Sorry do you mean that DrsPacket should be defined in this library?
It is a typedef struct that i defined in herkulex.c file.
2  Using Arduino / Programming Questions / error in library file on: November 13, 2012, 03:39:50 am
An error occurred when i tried to upload the file into arduino atmega2560. Below is one of the library files where the error is highlighted at.
The error says:
Code:
herkulex.h:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'herkulex'
herkulex.c:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
herkulex.c:166: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
herkulex.c:172: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
herkulex.c:194: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
herkulex.c:285: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token

And the 'class' word in this file is highlighted.
 
May I know what's wrong with this code? Thanks!

code:

Code:
#ifndef herkulex_lib
#define herkulex_lib

#include <Arduino.h>
#include <Wire.h>
#include<inttypes.h>

class herkulex
{
  public:
    herkulex();
    void hklx_Init(unsigned long ulBaudRate);
    void hklx_SendPacket(DrsPacket stPacket);
    unsigned char hklx_ucReceivePacket(DrsPacket *pstPacket);
    void hklx_RemoveInvalidData(void);

//no private  
};

#endif /* HERKULEX_H_ */


Moderator edit: [code] [/code] tags added.
3  Using Arduino / Programming Questions / Re: expected primary-expression before '.' token on: November 10, 2012, 11:12:13 pm
the error is highlighted at these 2 lines actually:
1) stPacket.ucHeader[0] = HEADER;
2) stPacket.ucHeader[1] = HEADER; 

DrsData is defined ontop of that 18 lines of code like this:

typedef union DrsData
  {
   unsigned char   ucData[MAX_PACKET_SIZE-MIN_PACKET_SIZE];
   
    DrsRWData      stRWData;
    DrsIJogData      stIJogData;
    DrsSJogData      stSJogData;
  }DrsData;
4  Using Arduino / Programming Questions / expected primary-expression before '.' token on: November 10, 2012, 10:14:25 pm
Hi I experienced an error that says "expected primary-expression before '.' token" at this line. May I know what is wrong with this code?


This is where the error is highlighted:

  typedef struct DrsPacket
  {
   unsigned char   ucHeader[2];
   unsigned char   ucPacketSize;
   unsigned char   ucChipID;
   unsigned char   ucCmd;
   unsigned char   ucCheckSum1;
   unsigned char   ucCheckSum2;
    DrsData      unData;
  }DrsPacket;

 // void hklx_SendPacket(DrsPacket stPacket){
void hklx_SendPacket(DrsPacket stPacket){
   unsigned char i;
        DrsPacket stPacket;
           
   // declare header
   stPacket.ucHeader[0] = HEADER;
   stPacket.ucHeader[1] = HEADER;

Thanks!
5  Using Arduino / Programming Questions / variables undeclared on: November 08, 2012, 10:01:41 am
Hi I have experienced an error in my code which states that the variables are not declared in setup. However, I have actually declared them in the other files which I have added into the same .ino file. As the files that I have added in as libaries are .cpp files, I am wondering if Arduino doesn't recognise the language and hence the variables are not declared?
Pages: [1]