-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test.cpp not work #1
Comments
Hi alfredopons, Currently this program is only a work in progress and I couldn't test it with a variety of devices. But for now it works fine with the RM5-HD. Maybe the issue lies in the poll loop to read the coin data. Because without polling, the coin acceptor wont accept any coins (that's at least the case with the RM5-HD). At first you can replace the test with the following code, that should accept all coins in theory: #include <cctalk.hpp>
#include <iostream>
cctalk::Bus::Command makePollCommand() {
cctalk::Bus::Command pollCommand;
pollCommand.destination = 2;
pollCommand.source = 1;
pollCommand.header = cctalk::Bus::READ_BUFFERED_CREDIT_OR_ERROR_CODES;
return pollCommand;
}
typedef std::function<void (std::optional<cctalk::Bus::DataCommand>)> Callback;
int main() {
boost::asio::io_context ioContext;
cctalk::Bus bus(ioContext);
if (!bus.open("/dev/ttyUSB0")) {
return 1;
}
Callback pollCallback, modifyStatusCallback, modifyMasterStatusCallback;
unsigned char requestData[] = {255, 255};
cctalk::Bus::DataCommand command;
command.destination = 2;
command.source = 1;
command.header = cctalk::Bus::MODIFY_INHIBIT_STATUS;
command.data = requestData;
command.length = 2;
bus.send(command);
bus.receive(1, modifyStatusCallback);
modifyStatusCallback = [modifyMasterStatusCallback, &bus, &command] (std::optional<cctalk::Bus::DataCommand> response) {
command.header = cctalk::Bus::MODIFY_MASTER_INHIBIT_STATE;
bus.send(command);
bus.receive(1, modifyMasterStatusCallback);
};
modifyMasterStatusCallback = [pollCallback, &bus] (std::optional<cctalk::Bus::DataCommand> response) {
auto pollCommand = makePollCommand();
bus.send(pollCommand);
bus.receive(1, pollCallback);
};
pollCallback = [pollCallback, &bus] (std::optional<cctalk::Bus::DataCommand> response) {
auto pollCommand = makePollCommand();
bus.send(pollCommand);
bus.receive(1, pollCallback);
};
ioContext.run();
} Unfortunately I could not test the code, but I hope it works! I'm looking forward hearing from you. |
Hello, In execution: terminate called after throwing an instance of 'std::logic_error' |
Oh that was my fault. bus.receive(1, modifyStatusCallback); |
If I reverse the order, it's still the same thing. modifyStatusCallback = [modifyMasterStatusCallback, &bus, &command] (std::optional<cctalk::Bus::DataCommand> response) {
command.header = cctalk::Bus::MODIFY_MASTER_INHIBIT_STATE;
bus.send(command);
bus.receive(1, modifyMasterStatusCallback);
};
bus.receive(1, modifyStatusCallback);
|
Can you try to capture the captured callback in the three lambdas by reference? |
It doesn't work either. Does it work for you? |
I can not test it right now but the last commit worked fine for me. |
Hello, I've tried it with the devices: NRI G-13 and Eagle V2 and Jofemar. Can you test it with any peripherals other than RM5-HD? I would like to test my acceptors in C++, but no Github project works, and there are many of them. Thanks VJSchneid |
Unfortunately I am not in office for two weeks. Therefor I can not test any peripheral for now. But maybe the error code from your CoinAcceptors can help. To print the error code out you need to add the follwing line: diff --git a/src/coinAcceptor.cpp b/src/coinAcceptor.cpp
index fd441cd..3f4ce27 100644
--- a/src/coinAcceptor.cpp
+++ b/src/coinAcceptor.cpp
@@ -250,6 +250,7 @@ namespace cctalk {
void CoinAcceptor::handlePollLoop(std::optional<Bus::DataCommand> command) {
if (command && command->length >= 3) {
if (command->data[0] != lastCounter) {
+ std::cout << "buffered error-code: " << (int)(command->data[2]) << std::endl;
lastCounter = command->data[0];
unsigned char lastCoinId = command->data[1];
if (lastCoinId > 0 && lastCoinId <= supportedCoins.size()) { That should at least print sth. when a coin is inserted. |
Thanks Viktor. You enjoy your vacation now and we'll talk about it later. |
Hello Viktor, have you been able to solve the problem? Thanks |
Hello Alfredo, unfortunately some other projects had priority at work. Therefor I didn't looked more closely into this since last time. Maybe it's a timing problem, because the program does currently not delay its poll requests. Thank you! |
Hello,
I tried your test and read the coin acceptor perfectly. Read the currency table:
It also activates the coins:
But he doesn't really accept any coins. They're all rejected.
I've tried it with the devices: NRI G-13 and Eagle V2
Can you help me?
Thanks
The text was updated successfully, but these errors were encountered: