|
Payout
A thin wrapper around the SSP protocol from ITL
|
Main source file for the payoutd daemon. More...
#include <ctype.h>#include <errno.h>#include <fcntl.h>#include <getopt.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <signal.h>#include <sys/types.h>#include <sys/stat.h>#include "ssp_commands.h"#include <jansson.h>#include <hiredis/hiredis.h>#include <hiredis/async.h>#include <hiredis/adapters/libevent.h>#include <syslog.h>#include <uuid/uuid.h>#include "StringBuffer.h"#include "StringBuffer.c"
Data Structures | |
| struct | m_device |
| Structure which describes an actual physical ITL device. More... | |
| struct | m_metacash |
| Structure which contains the generic setup data and the device structures for our two ITL devices. More... | |
| struct | m_command |
| Structure which describes an actual command which we received in one of our request topics. More... | |
Macros | |
| #define | SSP_CMD_GET_FIRMWARE_VERSION 0x20 |
| Magic Constant for the "GET FIRMWARE VERSION" command ID as specified in SSP. | |
| #define | SSP_CMD_GET_DATASET_VERSION 0x21 |
| Magic Constant for the "GET DATASET VERSION" command ID as specified in SSP. | |
| #define | SSP_CMD_GET_ALL_LEVELS 0x22 |
| Magic Constant for the "GET ALL LEVELS" command ID as specified in SSP. | |
| #define | SSP_CMD_SET_DENOMINATION_LEVEL 0x34 |
| Magic Constant for the "SET DENOMINATION LEVEL" command ID as specified in SSP. | |
| #define | SSP_CMD_LAST_REJECT_NOTE 0x17 |
| Magic Constant for the "LAST REJECT NOTE" command ID as specified in SSP. | |
| #define | SSP_CMD_CONFIGURE_BEZEL 0x54 |
| Magic Constant for the "CONFIGURE BEZEL" command ID as specified in SSP. | |
| #define | SSP_CMD_SMART_EMPTY 0x52 |
| Magic Constant for the "SMART EMPTY" command ID as specified in SSP. | |
| #define | SSP_CMD_SET_REFILL_MODE 0x30 |
| Magic Constant for the "SET REFILL MODE " command ID as specified in SSP. | |
| #define | SSP_CMD_DISPLAY_OFF 0x4 |
| Magic Constant for the "DISPLAY OFF" command ID as specified in SSP. | |
| #define | SSP_CMD_DISPLAY_ON 0x3 |
| Magic Constant for the "DISPLAY ON" command ID as specified in SSP. | |
Functions | |
| int | mcSspOpenSerialDevice (struct m_metacash *metacash) |
| Opens the serial device. | |
| void | mcSspCloseSerialDevice (struct m_metacash *metacash) |
| Closes the serial device. | |
| void | mcSspSetupCommand (SSP_COMMAND *sspC, int deviceId) |
| Initializes the SSP_COMMAND structure. | |
| void | mcSspInitializeDevice (SSP_COMMAND *sspC, unsigned long long key, struct m_device *device) |
| Initializes an ITL hardware device via SSP. | |
| void | mcSspPollDevice (struct m_device *device, struct m_metacash *metacash) |
| Issues a poll command to the hardware and dispatches the response to the event handler function of the device. | |
| SSP_RESPONSE_ENUM | mc_ssp_empty (SSP_COMMAND *sspC) |
| Implements the "EMPTY" command from the SSP Protocol. | |
| SSP_RESPONSE_ENUM | mc_ssp_smart_empty (SSP_COMMAND *sspC) |
| Implements the "SMART EMPTY" command from the SSP Protocol. | |
| SSP_RESPONSE_ENUM | mc_ssp_configure_bezel (SSP_COMMAND *sspC, unsigned char r, unsigned char g, unsigned char b, unsigned char volatileOption, unsigned char bezelTypeOption) |
| Implements the "CONFIGURE BEZEL" command from the SSP Protocol. | |
| SSP_RESPONSE_ENUM | mc_ssp_display_on (SSP_COMMAND *sspC) |
| Implements the "DISPLAY ON" command from the SSP Protocol. | |
| SSP_RESPONSE_ENUM | mc_ssp_display_off (SSP_COMMAND *sspC) |
| Implements the "DISPLAY OFF" command from the SSP Protocol. | |
| SSP_RESPONSE_ENUM | mc_ssp_last_reject_note (SSP_COMMAND *sspC, unsigned char *reason) |
| Implements the "LAST REJECT NOTE" command from the SSP Protocol. | |
| SSP_RESPONSE_ENUM | mc_ssp_set_refill_mode (SSP_COMMAND *sspC) |
| Implements the "SET REFILL MODE" command from the SSP Protocol. | |
| SSP_RESPONSE_ENUM | mc_ssp_get_all_levels (SSP_COMMAND *sspC, char **json) |
| Implements the "GET ALL LEVELS" command from the SSP Protocol. | |
| SSP_RESPONSE_ENUM | mc_ssp_set_denomination_level (SSP_COMMAND *sspC, int amount, int level, const char *cc) |
| Implements the "SET DENOMINATION LEVEL" command from the SSP Protocol. | |
| SSP_RESPONSE_ENUM | mc_ssp_float (SSP_COMMAND *sspC, const int value, const char *cc, const char option) |
| Implements the "FLOAT" command from the SSP Protocol. | |
| SSP_RESPONSE_ENUM | mc_ssp_channel_security_data (SSP_COMMAND *sspC) |
| Implements the "CHANNEL SECURITY DATA" command from the SSP Protocol. | |
| SSP_RESPONSE_ENUM | mc_ssp_get_firmware_version (SSP_COMMAND *sspC, char *firmwareVersion) |
| Implements the "GET FIRMWARE VERSION" command from the SSP Protocol. | |
| SSP_RESPONSE_ENUM | mc_ssp_get_dataset_version (SSP_COMMAND *sspC, char *datasetVersion) |
| Implements the "GET DATASET VERSION" command from the SSP Protocol. | |
| int | parseCmdLine (int argc, char *argv[], struct m_metacash *metacash) |
| Parse the command line arguments. | |
| void | setup (struct m_metacash *metacash) |
| Initializes and configures redis, libevent and the hardware. | |
| void | hopperEventHandler (struct m_device *device, struct m_metacash *metacash, SSP_POLL_DATA6 *poll) |
| Callback function used for inspecting and publishing events reported by the Hopper hardware. More... | |
| void | validatorEventHandler (struct m_device *device, struct m_metacash *metacash, SSP_POLL_DATA6 *poll) |
| Callback function used for inspecting and publishing events reported by the Validator hardware. More... | |
| void | signalHandler (int signal) |
| Signal handler. | |
| void | hardwareWaitTime () |
| Waits for 300ms each time called. More... | |
| redisAsyncContext * | connectRedis (struct m_metacash *metacash) |
| Connect to redis and return a new redisAsyncContext. | |
| void | cbOnPollEvent (int fd, short event, void *privdata) |
| Callback function for libEvent timer triggered "Poll" event. More... | |
| void | cbOnCheckQuitEvent (int fd, short event, void *privdata) |
| Callback function for libEvent timer triggered "CheckQuit" event. | |
| void | cbOnMetacashMessage (redisAsyncContext *c, void *r, void *privdata) |
| Callback function triggered by an incoming message in the "metacash" topic. | |
| int | isCommand (struct m_command *cmd, const char *command) |
| Test if cmd.command equals command. | |
| int | publishPayoutEvent (char *format,...) |
| Helper function to publish a message to the "payout-event" topic. | |
| int | publishHopperEvent (char *format,...) |
| Helper function to publish a message to the "hopper-event" topic. | |
| int | publishValidatorEvent (char *format,...) |
| Helper function to publish a message to the "validator-event" topic. | |
| int | replyWith (char *topic, char *format,...) |
| Helper function to publish a message to the given topic. More... | |
| int | replyWithPropertyError (struct m_command *cmd, char *name) |
| Helper function to publish a reply to a message which was missing a mandatory property (or the property was of the wrong type). More... | |
| int | replyWithSspResponse (struct m_command *cmd, SSP_RESPONSE_ENUM response) |
| Helper function to publish a reply to a message which contains a human readable version of the SSP response. More... | |
| void | handleQuit (struct m_command *cmd) |
| Handles the JSON "quit" command. | |
| void | handleEmpty (struct m_command *cmd) |
| Handles the JSON "empty" command. | |
| void | handleSmartEmpty (struct m_command *cmd) |
| Handles the JSON "smart-empty" command. | |
| void | handlePayout (struct m_command *cmd) |
| Handles the JSON "do-payout" and "test-payout" commands. | |
| void | handleFloat (struct m_command *cmd) |
| Handles the JSON "do-float" and "test-float" commands. | |
| void | dbgDisplayInhibits (unsigned char inhibits) |
| Print inhibits debug output. | |
| void | handleEnableChannels (struct m_command *cmd) |
| Handles the JSON "enable-channels" command. | |
| void | handleDisableChannels (struct m_command *cmd) |
| Handles the JSON "disable-channels" command. | |
| void | handleInhibitChannels (struct m_command *cmd) |
| Handles the JSON "inhibit-channels" command. | |
| void | handleEnable (struct m_command *cmd) |
| Handles the JSON "enable" command. | |
| void | handleDisable (struct m_command *cmd) |
| Handles the JSON "disable" command. | |
| void | handleSetDenominationLevels (struct m_command *cmd) |
| Handles the JSON "set-denomination-levels" command. | |
| void | handleGetAllLevels (struct m_command *cmd) |
| Handles the JSON "get-all-levels" command. | |
| void | handleGetFirmwareVersion (struct m_command *cmd) |
| Handles the JSON "get-firmware-version" command. | |
| void | handleGetDatasetVersion (struct m_command *cmd) |
| Handles the JSON "get-dataset-version" command. | |
| void | handleLastRejectNote (struct m_command *cmd) |
| Handles the JSON "last-reject-note" command. | |
| void | handleChannelSecurityData (struct m_command *cmd) |
| Handles the JSON "channel-security" command. | |
| void | handleTest (struct m_command *cmd) |
| Handles the JSON "test" command. | |
| void | handleConfigureBezel (struct m_command *cmd) |
| Handles the JSON "configure-bezel" command. | |
| void | cbOnRequestMessage (redisAsyncContext *c, void *r, void *privdata) |
| Callback function triggered by an incoming message in either the "hopper-request" or "validator-request" topic. More... | |
| void | cbOnConnectPublishContext (const redisAsyncContext *c, int status) |
| Callback function triggered by the redis client on connecting with the "publish" context. | |
| void | cbOnDisconnectPublishContext (const redisAsyncContext *c, int status) |
| Callback function triggered by the redis client on disconnecting with the "publish" context. | |
| void | cbOnConnectSubscribeContext (const redisAsyncContext *c, int status) |
| Callback function triggered by the redis client on connecting with the "subscribe" context. | |
| void | cbOnDisconnectSubscribeContext (const redisAsyncContext *c, int status) |
| Callback function triggered by the redis client on disconnecting with the "subscribe" context. | |
| int | main (int argc, char *argv[]) |
| Supports arguments -h (redis hostname), -p (redis port), -d (serial device name) and -?. More... | |
Variables | |
| redisAsyncContext * | redisPublishCtx = NULL |
| redis context used for publishing messages | |
| redisAsyncContext * | redisSubscribeCtx = NULL |
| redis context used for subscribing to topics | |
| const char | SSP_OPTION_ROUTE_CASHBOX = 0x01 |
| Magic Constant for the "route to cashbox" option as specified in SSP. | |
| const char | SSP_OPTION_ROUTE_STORAGE = 0x00 |
| Magic Constant for the "route to storage" option as specified in SSP. | |
| const unsigned char | SSP_OPTION_VOLATILE = 0x00 |
| Magic Constant for the "volatile" option in configure bezel as specified in SSP. | |
| const unsigned char | SSP_OPTION_NON_VOLATILE = 0x01 |
| Magic Constant for the "non volatile" option in configure bezel as specified in SSP. | |
| const unsigned char | SSP_OPTION_SOLID = 0x00 |
| Magic Constant for the "solid" option in configure bezel as specified in SSP. | |
| const unsigned char | SSP_OPTION_FLASHING = 0x01 |
| Magic Constant for the "flashing" option in configure bezel as specified in SSP. | |
| const unsigned char | SSP_OPTION_DISABLED = 0x02 |
| Magic Constant for the "disabled" option in configure bezel as specified in SSP. | |
| static const unsigned long long | DEFAULT_KEY = 0x123456701234567LL |
| static const char * | CURRENCY = "EUR" |
| int | receivedSignal = 0 |
| Set by the signalHandler function and checked in cbCheckQuit. | |
Main source file for the payoutd daemon.
In a nutshell:
| void cbOnPollEvent | ( | int | fd, |
| short | event, | ||
| void * | privdata | ||
| ) |
Callback function for libEvent timer triggered "Poll" event.
Details only to get graph.

| void cbOnRequestMessage | ( | redisAsyncContext * | c, |
| void * | r, | ||
| void * | privdata | ||
| ) |
Callback function triggered by an incoming message in either the "hopper-request" or "validator-request" topic.
Details only to get graph.

| void hardwareWaitTime | ( | ) |
Waits for 300ms each time called.
Details only to get graph.

| void hopperEventHandler | ( | struct m_device * | device, |
| struct m_metacash * | metacash, | ||
| SSP_POLL_DATA6 * | poll | ||
| ) |
Callback function used for inspecting and publishing events reported by the Hopper hardware.
Details only to get graph.

| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Supports arguments -h (redis hostname), -p (redis port), -d (serial device name) and -?.
Warning: both "calls" to hopperEventHandler() and validatorEventHandler() in the callgraph are false positives!

| int replyWith | ( | char * | topic, |
| char * | format, | ||
| ... | |||
| ) |
Helper function to publish a message to the given topic.
Details only to get graph.

| int replyWithPropertyError | ( | struct m_command * | cmd, |
| char * | name | ||
| ) |
Helper function to publish a reply to a message which was missing a mandatory property (or the property was of the wrong type).
Details only to get graph.

| int replyWithSspResponse | ( | struct m_command * | cmd, |
| SSP_RESPONSE_ENUM | response | ||
| ) |
Helper function to publish a reply to a message which contains a human readable version of the SSP response.
Details only to get graph.

| void validatorEventHandler | ( | struct m_device * | device, |
| struct m_metacash * | metacash, | ||
| SSP_POLL_DATA6 * | poll | ||
| ) |
Callback function used for inspecting and publishing events reported by the Validator hardware.
Details only to get graph.

1.8.11