This question is a little related to this one: How to compile and upload the specific (.cpp + .h) code?
I've installed MdbBillValidator to my arduino libraries collection. I tried both on ubuntu & windows.
How can I include it? Default inclusion, by arduino ide, was:
#include <MdbSerial.h>
#include <wiring_private.h>
#include <MdbBillValidator.h>
#include <MdbMaster.h>
#include <Arduino.h>
void loop() {
}
void setup() {
}
And here is error comes in:
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp: In function ‘void __vector_37()’:
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:289:23: error: ‘TXB8’ was not declared in this scope
UCSR1B |= (1 << TXB8);
^
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:291:24: error: ‘TXB8’ was not declared in this scope
UCSR1B &= ~(1 << TXB8);
^
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp: In function ‘void __vector_52()’:
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:314:23: error: ‘TXB8’ was not declared in this scope
UCSR2B |= (1 << TXB8);
^
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:316:24: error: ‘TXB8’ was not declared in this scope
UCSR2B &= ~(1 << TXB8);
^
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp: In function ‘void __vector_55()’:
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:339:23: error: ‘TXB8’ was not declared in this scope
UCSR3B |= (1 << TXB8);
^
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:341:24: error: ‘TXB8’ was not declared in this scope
UCSR3B &= ~(1 << TXB8);
^
In file included from /usr/lib/avr/include/avr/iom2560.h:38:0,
from /usr/lib/avr/include/avr/io.h:160,
from /usr/lib/avr/include/avr/pgmspace.h:88,
from /home/asiniy/sketchbook/libraries/MdbBillValidator/Arduino.h:8,
from /home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:31:
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp: At global scope:
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:554:135: error: expected ‘)’ before numeric constant
MdbSerial MdbPort1(&rx_buffer1, &tx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UCSR1C, &UDR1, RXEN1, TXEN1, RXCIE1, UDRIE1, U2X1 UCSZ12, UCSZ11, UCSZ10, UPM11, UPM10, UMSEL11, UMSEL10);
^
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:554:189: error: no matching function for call to ‘MdbSerial::MdbSerial(ring_buffer*, ring_buffer*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, int, int, int, int, int, int, int, int, int, int, int)’
MdbSerial MdbPort1(&rx_buffer1, &tx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UCSR1C, &UDR1, RXEN1, TXEN1, RXCIE1, UDRIE1, U2X1 UCSZ12, UCSZ11, UCSZ10, UPM11, UPM10, UMSEL11, UMSEL10);
^
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:554:189: note: candidates are:
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:352:1: note: MdbSerial::MdbSerial(ring_buffer*, ring_buffer*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
MdbSerial::MdbSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer,
^
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:352:1: note: candidate expects 20 arguments, 19 provided
In file included from /home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:38:0:
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.h:52:7: note: MdbSerial::MdbSerial(const MdbSerial&)
class MdbSerial
^
/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.h:52:7: note: candidate expects 1 argument, 19 provided
What I need to do to avoid this error and get the code worked?
1 Answer 1
Could you try adding this to your program?
#define RXB8 1
#define TXB8 0
#define UPE 2
#define OVR 3
#define FE 4
#define UDRE 5
#define RXC 7
#define FRAMING_ERROR (1<<FE)
#define PARITY_ERROR (1<<UPE)
#define DATA_OVERRUN (1<<OVR)
#define DATA_REGISTER_EMPTY (1<<UDRE)
#define RX_COMPLETE (1<<RXC)
I found someone with similar code, who had these defines and as your code seems to miss/cannot find something, this might fix it. Though I'm not sure if these defines apply in your specific implementation. For that I should have to see the code where the error is pointing at.
-
Regards, done compiling! What do you think about it? Why author set these values empty?Alex Antonov– Alex Antonov2015年04月02日 04:00:00 +00:00Commented Apr 2, 2015 at 4:00
-
1He might have had another file, that he didn't upload to github. You do have an idea of what these values do? Because TXB8 is bit 0 from the register, so instead of using 0, you can use a
define
or definition, which is easier to understand. Also, you should check the error message when it won't compile.error: ‘TXB8’ was not declared in this scope
Which mean that the compiler could't find the variable 'TXB8'. So either missing a variable, out of scope, or missing a define ;D And if you look at the code on that position, you should see what is missing there.aaa– aaa2015年04月02日 06:05:56 +00:00Commented Apr 2, 2015 at 6:05 -
I asked him at github about this. In general, this library allows to connect mdb bus with PC through arduinoAlex Antonov– Alex Antonov2015年04月02日 06:08:54 +00:00Commented Apr 2, 2015 at 6:08
-
btw, it's still don't work on windows. I get this:
C:\Users\User\Documents\Arduino\libraries\MdbBillValidator\MdbSerial.cpp:554:135: error: expected ')' before numeric constant MdbSerial MdbPort1(&rx_buffer1, &tx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UCSR1C, &UDR1, RXEN1, TXEN1, RXCIE1, UDRIE1, U2X1 UCSZ12, UCSZ11, UCSZ10, UPM11, UPM10, UMSEL11, UMSEL10);
Alex Antonov– Alex Antonov2015年04月02日 06:22:18 +00:00Commented Apr 2, 2015 at 6:22 -
1Thanks for helping, this was a typo: github.com/justintconroy/MdbBillValidator/pull/4Alex Antonov– Alex Antonov2015年04月02日 07:17:57 +00:00Commented Apr 2, 2015 at 7:17