Exemplo n.º 1
0
SSP_RESPONSE_ENUM ssp_unit_data(SSP_COMMAND_SETUP setup, SSP_UNIT_DATA * sud)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    int i;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 1;
    sspC.CommandData[0] = SSP_CMD_UNIT_DATA;
    resp = _ssp_return_values(setup.port, &sspC);
    if (resp == SSP_RESPONSE_OK)
    {
        sud->UnitType = sspC.ResponseData[1];
        for (i = 0; i < 4; ++i)
            sud->FirmwareVersion[i] = sspC.ResponseData[i+2];
        sud->FirmwareVersion[i] = 0; //NULL TERMINATOR

        for (i = 0; i < 3; ++i)
            sud->CountryCode[i] = sspC.ResponseData[i+6];
        sud->CountryCode[i] = 0; //NULL TERMINATOR

        sud->ValueMultiplier = 0;
        for (i = 0; i < 3; ++i)
            sud->ValueMultiplier += ((unsigned long)sspC.ResponseData[i+9] << ((2-i)*8));

        sud->ProtocolVersion = sspC.ResponseData[12];

    }
    return resp;
}
Exemplo n.º 2
0
// Send an SSP sync (0x11)
SSP_RESPONSE_ENUM ssp6_sync(SSP_COMMAND *sspC) {
  SSP_RESPONSE_ENUM resp;

  sspC->CommandDataLength = 1;
  sspC->CommandData[0] = SSP_CMD_SYNC;
  resp = _ssp_return_values(sspC);
  return resp;
}
Exemplo n.º 3
0
// run a calibration sequence on the hopper
SSP_RESPONSE_ENUM ssp6_run_calibration(SSP_COMMAND *sspC) {
  SSP_RESPONSE_ENUM resp;

  sspC->CommandDataLength = 1;
  sspC->CommandData[0] = SSP_CMD_RUN_CALIBRATION;
  resp = _ssp_return_values(sspC);
  return resp;
}
Exemplo n.º 4
0
// disable the validator
SSP_RESPONSE_ENUM ssp6_disable(SSP_COMMAND *sspC) {
  SSP_RESPONSE_ENUM resp;

  sspC->CommandDataLength = 1;
  sspC->CommandData[0] = SSP_CMD_DISABLE;
  resp = _ssp_return_values(sspC);
  return resp;
}
Exemplo n.º 5
0
// payout the next note from an NV11
SSP_RESPONSE_ENUM ssp6_payout_note(SSP_COMMAND *sspC) {
  SSP_RESPONSE_ENUM resp;
  sspC->CommandDataLength = 1;
  sspC->CommandData[0] = SSP_CMD_PAYOUT_NOTE;

  resp = _ssp_return_values(sspC);
  return resp;
}
Exemplo n.º 6
0
// Send an SSP host protocol version (0x06)
SSP_RESPONSE_ENUM ssp6_host_protocol(SSP_COMMAND *sspC,const unsigned char host_protocol) {
  SSP_RESPONSE_ENUM resp;

  sspC->CommandDataLength = 2;
  sspC->CommandData[0] = SSP_CMD_HOST_PROTOCOL;
  sspC->CommandData[1] = host_protocol;
  resp = _ssp_return_values(sspC);
  return resp;
}
Exemplo n.º 7
0
// stack the next note in the NV11
SSP_RESPONSE_ENUM ssp6_stack_note(SSP_COMMAND *sspC) {
  SSP_RESPONSE_ENUM resp;

  sspC->CommandDataLength = 1;
  sspC->CommandData[0] = SSP_CMD_STACK_NOTE;

  resp = _ssp_return_values(sspC);
  return resp;
}
Exemplo n.º 8
0
SSP_RESPONSE_ENUM ssp_enable_higher_protocol_events(SSP_COMMAND_SETUP setup)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 1;
    sspC.CommandData[0] = SSP_CMD_ENABLE_HIGHER_PROTOCOL;
    resp = _ssp_return_values(setup.port, &sspC);
    return resp;
}
Exemplo n.º 9
0
SSP_RESPONSE_ENUM ssp_hold_note(SSP_COMMAND_SETUP setup)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 1;
    sspC.CommandData[0] = SSP_CMD_HOLD;
    resp = _ssp_return_values(setup.port, &sspC);
    return resp;
}
Exemplo n.º 10
0
SSP_RESPONSE_ENUM ssp_display_on(SSP_COMMAND_SETUP setup)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 1;
    sspC.CommandData[0] = SSP_CMD_BULB_ON;
    resp = _ssp_return_values(setup.port, &sspC);
    return resp;
}
Exemplo n.º 11
0
SSP_RESPONSE_ENUM ssp_halt_payout(SSP_COMMAND_SETUP setup)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 1;
    sspC.CommandData[0] = SSP_CMD_HALT_PAYOUT;
    resp = _ssp_return_values(setup.port, &sspC);
    return resp;
}
Exemplo n.º 12
0
SSP_RESPONSE_ENUM ssp_host_protocol(SSP_COMMAND_SETUP setup,const unsigned char host_protocol)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 2;
    sspC.CommandData[0] = SSP_CMD_HOST_PROTOCOL;
    sspC.CommandData[1] = host_protocol;
    resp = _ssp_return_values(setup.port, &sspC);
    return resp;
}
Exemplo n.º 13
0
// send a set inhibits command
SSP_RESPONSE_ENUM ssp6_set_inhibits(SSP_COMMAND *sspC, const unsigned char lowchannels,
                                    const unsigned char highchannels) {
  SSP_RESPONSE_ENUM resp;

  sspC->CommandDataLength = 3;
  sspC->CommandData[0] = SSP_CMD_SET_INHIBITS;
  sspC->CommandData[1] = lowchannels;
  sspC->CommandData[2] = highchannels;
  resp = _ssp_return_values(sspC);
  return resp;
}
Exemplo n.º 14
0
SSP_RESPONSE_ENUM ssp_poll(SSP_COMMAND_SETUP setup,SSP_POLL_DATA * poll_response)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    unsigned char i,j;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 1;
    sspC.CommandData[0] = SSP_CMD_POLL;
    resp = _ssp_return_values(setup.port, &sspC);
    if (resp == SSP_RESPONSE_OK)
    {
        poll_response->event_count = 0;
        for (i = 1; i < sspC.ResponseDataLength; ++i)
        {
            poll_response->events[poll_response->event_count].event = sspC.ResponseData[i];
            switch (sspC.ResponseData[i])
            {
            //all these commands have one data byte
            case SSP_POLL_CREDIT:
            case SSP_POLL_FRAUD_ATTEMPT:
            case SSP_POLL_READ:
            case SSP_POLL_CLEARED_FROM_FRONT:
            case SSP_POLL_CLEARED_INTO_CASHBOX:
                i++; //move onto the data
                poll_response->events[poll_response->event_count].data = sspC.ResponseData[i];
                break;
            //all these commands have 4 data bytes
            case SSP_POLL_DISPENSING:
            case SSP_POLL_DISPENSED:
            case SSP_POLL_JAMMED:
            case SSP_POLL_HALTED:
            case SSP_POLL_FLOATING:
            case SSP_POLL_FLOATED:
            case SSP_POLL_TIMEOUT:
            case SSP_POLL_INCOMPLETE_PAYOUT:
            case SSP_POLL_INCOMPLETE_FLOAT:
            case SSP_POLL_CASHBOX_PAID:
            case SSP_POLL_COIN_CREDIT:
                poll_response->events[poll_response->event_count].data = 0;
                for (j = 0; j < 4; ++j)
                {
                    i++; //move through the data
                    poll_response->events[poll_response->event_count].data += (((unsigned long)sspC.ResponseData[i]) << (8*i));
                }
                break;
            default: //every other command has no data bytes
                poll_response->events[poll_response->event_count].data = 0;
                break;
            }
            poll_response->event_count++;
        }
    }
    return resp;
}
Exemplo n.º 15
0
SSP_RESPONSE_ENUM ssp_set_inhibits(SSP_COMMAND_SETUP setup,const unsigned char lowchannels, const unsigned char highchannels)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 3;
    sspC.CommandData[0] = SSP_CMD_SET_INHIBITS;
    sspC.CommandData[1] = lowchannels;
    sspC.CommandData[2] = highchannels;
    resp = _ssp_return_values(setup.port, &sspC);
    return resp;
}
Exemplo n.º 16
0
SSP_RESPONSE_ENUM ssp_payout_amount(SSP_COMMAND_SETUP setup, const unsigned long amount)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    unsigned char i;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 5;
    sspC.CommandData[0] = SSP_CMD_PAYOUT_VALUE;
    for (i = 0; i < 4; ++i)
        sspC.CommandData[i+1] = ((amount >> (8*i))& 0xFF);
    resp = _ssp_return_values(setup.port, &sspC);
    return resp;
}
Exemplo n.º 17
0
// send an enable payout command
SSP_RESPONSE_ENUM ssp6_enable_payout(SSP_COMMAND *sspC, const char type) {
  SSP_RESPONSE_ENUM resp;

  sspC->CommandDataLength = 1;
  sspC->CommandData[0] = SSP_CMD_ENABLE_PAYOUT_DEVICE;

  if (type == 0x07) {
    sspC->CommandDataLength = 2;
    sspC->CommandData[1] = 0x00;
  }

  resp = _ssp_return_values(sspC);
  return resp;
}
Exemplo n.º 18
0
SSP_RESPONSE_ENUM ssp_set_routing(SSP_COMMAND_SETUP setup,const unsigned long value, const unsigned char route)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    unsigned char i;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 6;
    sspC.CommandData[0] = SSP_CMD_SET_ROUTING;
    sspC.CommandData[1] = route;
    for (i = 0; i < 4; ++i)
        sspC.CommandData[i+2] = ((value >> (8*i))& 0xFF);
    resp = _ssp_return_values(setup.port, &sspC);
    return resp;
}
Exemplo n.º 19
0
SSP_RESPONSE_ENUM ssp_last_reject(SSP_COMMAND_SETUP setup, unsigned char * last_reject_reason)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 1;
    sspC.CommandData[0] = SSP_CMD_LAST_REJECT;
    resp = _ssp_return_values(setup.port, &sspC);
    *last_reject_reason = 0;
    if (resp == SSP_RESPONSE_OK)
    {
        *last_reject_reason = sspC.ResponseData[1];
    }
    return resp;
}
Exemplo n.º 20
0
SSP_RESPONSE_ENUM ssp_set_coin_amount(SSP_COMMAND_SETUP setup, const unsigned long value, const unsigned short amount)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    unsigned char i;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 7;
    sspC.CommandData[0] = SSP_CMD_SET_COIN_AMOUNT;
    for (i = 0; i < 2; ++i)
        sspC.CommandData[i+1] = ((amount >> (8*i))& 0xFF);
    for (i = 0; i < 4; ++i)
        sspC.CommandData[i+3] = ((value >> (8*i))& 0xFF);
    resp = _ssp_return_values(setup.port, &sspC);
    return resp;
}
Exemplo n.º 21
0
SSP_RESPONSE_ENUM ssp_float_hopper(SSP_COMMAND_SETUP setup,const unsigned long value,  const unsigned long minimum_payout)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    unsigned char i;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 5;
    sspC.CommandData[0] = SSP_CMD_SET_ROUTING;
    for (i = 0; i < 2; ++i)
        sspC.CommandData[i+1] = ((minimum_payout >> (8*i))& 0xFF);
    for (i = 0; i < 4; ++i)
        sspC.CommandData[i+3] = ((value >> (8*i))& 0xFF);
    resp = _ssp_return_values(setup.port, &sspC);
    return resp;
}
Exemplo n.º 22
0
SSP_RESPONSE_ENUM ssp_get_coin_amount(SSP_COMMAND_SETUP setup, const unsigned long value, unsigned short * amount)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    unsigned char i;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 5;
    sspC.CommandData[0] = SSP_CMD_GET_COIN_AMOUNT;
    for (i = 0; i < 4; ++i)
        sspC.CommandData[i+3] = ((value >> (8*i))& 0xFF);
    resp = _ssp_return_values(setup.port, &sspC);
    *amount = 0;
    if (resp == SSP_RESPONSE_OK)
        *amount = (unsigned short)sspC.ResponseData[1] + (((unsigned short)sspC.ResponseData[2]) << 8);
    return resp;
}
Exemplo n.º 23
0
// Send an SSP payout command (0x33)
SSP_RESPONSE_ENUM ssp6_set_route(SSP_COMMAND *sspC, const int value, const char *cc, const char route) {
  SSP_RESPONSE_ENUM resp;
  int i;

  sspC->CommandDataLength = 9;
  sspC->CommandData[0] = SSP_CMD_SET_ROUTING;
  sspC->CommandData[1] = route;

  for (i=0; i<4; i++) {
    sspC->CommandData[i+2] = value >> (i*8);
  }
  for (i=0; i<3; i++) {
    sspC->CommandData[i+6] = cc[i];
  }
  resp = _ssp_return_values(sspC);
  return resp;
}
Exemplo n.º 24
0
SSP_RESPONSE_ENUM ssp_channel_security_data(SSP_COMMAND_SETUP setup, SSP_CHANNEL_DATA * scd)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    int i;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 1;
    sspC.CommandData[0] = SSP_CMD_CHANNEL_SECURITY;
    resp = _ssp_return_values(setup.port, &sspC);
    if (resp == SSP_RESPONSE_OK)
    {
        scd->NumberOfChannels = sspC.ResponseData[1];
        for (i = 0; i < scd->NumberOfChannels; ++i)
            scd->ChannelData[i] = sspC.ResponseData[i+2];
    }
    return resp;
}
Exemplo n.º 25
0
SSP_RESPONSE_ENUM ssp_get_serial(SSP_COMMAND_SETUP setup,unsigned long * serial )
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    unsigned char i;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 1;
    sspC.CommandData[0] = SSP_CMD_SERIAL_NUMBER;
    resp = _ssp_return_values(setup.port, &sspC);
    *serial = 0;
    if (resp == SSP_RESPONSE_OK)
    {
        for (i = 0; i < 4; ++i)
          *serial += (((unsigned long)sspC.ResponseData[i+1]) << (8*(3-i)));
    }
    return resp;
}
Exemplo n.º 26
0
// set the inhibits for the atached coinmech
SSP_RESPONSE_ENUM ssp6_set_coinmech_inhibits(SSP_COMMAND *sspC, unsigned int value,
                                             const char *cc, enum channel_state state) {
  SSP_RESPONSE_ENUM resp;
  int i;

  sspC->CommandDataLength = 7;
  sspC->CommandData[0] = SSP_CMD_SET_COINMECH_INHIBITS;
  sspC->CommandData[1] = state;
  sspC->CommandData[2] = value & 0xFF;
  sspC->CommandData[3] = (value >> 8) & 0xFF;

  for (i=0; i<3; i++) {
    sspC->CommandData[4+i] = cc[i];
  }
  resp = _ssp_return_values(sspC);
  return resp;
}
Exemplo n.º 27
0
// Send an SSP payout command (0x33)
SSP_RESPONSE_ENUM ssp6_payout(SSP_COMMAND *sspC, const int value, const char *cc, const char option) {
  SSP_RESPONSE_ENUM resp;
  int i;

  sspC->CommandDataLength = 9;
  sspC->CommandData[0] = SSP_CMD_PAYOUT_VALUE;

  for (i=0; i<4; i++) {
    sspC->CommandData[i+1] = value >> (i*8);
  }
  for (i=0; i<3; i++) {
    sspC->CommandData[i+5] = cc[i];
  }
  sspC->CommandData[8] = option;

  resp = _ssp_return_values(sspC);
  return resp;
}
Exemplo n.º 28
0
SSP_RESPONSE_ENUM ssp_setup_request(SSP_COMMAND_SETUP setup, SSP_SETUP_REQUEST_DATA * setup_request_data)
{
    SSP_COMMAND sspC;
    SSP_RESPONSE_ENUM resp;
    int i;
    int offset;
    _ssp_setup_command_structure(&setup,&sspC);
    sspC.CommandDataLength = 1;
    sspC.CommandData[0] = SSP_CMD_SETUP_REQUEST;
    resp = _ssp_return_values(setup.port, &sspC);
    if (resp == SSP_RESPONSE_OK)
    {
        offset = 1;
        setup_request_data->UnitType = sspC.ResponseData[offset++];
        for (i = 0; i < 4; ++i)
            setup_request_data->FirmwareVersion[i] = sspC.ResponseData[offset++];
        setup_request_data->FirmwareVersion[i] = 0; //NULL TERMINATOR

        for (i = 0; i < 3; ++i)
            setup_request_data->CountryCode[i] = sspC.ResponseData[offset++];
        setup_request_data->CountryCode[i] = 0; //NULL TERMINATOR

        setup_request_data->ValueMultiplier = 0;
        for (i = 0; i < 3; ++i)
            setup_request_data->ValueMultiplier += ((unsigned long)sspC.ResponseData[offset++] << ((2-i)*8));

        setup_request_data->ChannelValues.NumberOfChannels = sspC.ResponseData[offset++];
        setup_request_data->ChannelSecurity.NumberOfChannels = setup_request_data->ChannelValues.NumberOfChannels;

        for(i =0 ; i < setup_request_data->ChannelValues.NumberOfChannels; ++i)
            setup_request_data->ChannelValues.ChannelData[i] = sspC.ResponseData[offset++];

        for(i =0 ; i < setup_request_data->ChannelValues.NumberOfChannels; ++i)
            setup_request_data->ChannelSecurity.ChannelData[i] = sspC.ResponseData[offset++];

        setup_request_data->RealValueMultiplier = 0;
        for (i = 0; i < 3; ++i)
            setup_request_data->RealValueMultiplier += ((unsigned long)sspC.ResponseData[offset++] << ((2-i)*8));

        setup_request_data->ProtocolVersion = sspC.ResponseData[offset++];

    }
    return resp;
}
Exemplo n.º 29
0
// Send an SSP setup request (0x05), and parse the response into an SSP6_SETUP_REQUEST_DATA
SSP_RESPONSE_ENUM ssp6_setup_request(SSP_COMMAND *sspC, SSP6_SETUP_REQUEST_DATA *setup_request_data) {
  SSP_RESPONSE_ENUM resp;
  unsigned int i;
  int offset;

  // Send the setup request command
  sspC->CommandDataLength = 1;
  sspC->CommandData[0] = SSP_CMD_SETUP_REQUEST;
  resp = _ssp_return_values(sspC);

  // If the command succeeded parse the response
  if (resp == SSP_RESPONSE_OK) {
    offset = 1;
    // SSP unit type
    setup_request_data->UnitType = sspC->ResponseData[offset++];


    if (setup_request_data->UnitType == 0x03) {
      // If the unit is a SMART Hopper

      // Extract the firmware version
      for (i = 0; i < 4; ++i)
        setup_request_data->FirmwareVersion[i] = sspC->ResponseData[offset++];
      setup_request_data->FirmwareVersion[i] = '\n'; //NULL TERMINATOR

      // Country Code field is obsolete in SSPv6
      offset += 3;

      // Extract the SSP protocol version and the number of channels
      setup_request_data->ProtocolVersion = sspC->ResponseData[offset++];
      setup_request_data->NumberOfChannels = sspC->ResponseData[offset++];

      // For each channel, extract the channel value
      for (i=0; i<setup_request_data->NumberOfChannels; i++) {
        int j;
        setup_request_data->ChannelData[i].value = 0;
        for (j=0; j<2; j++)
          setup_request_data->ChannelData[i].value += sspC->ResponseData[offset++] << (j*8);
      }
      // For each channel, extract the country code
      for (i=0; i<setup_request_data->NumberOfChannels; i++) {
        int j;
        for (j=0; j<3; j++)
          setup_request_data->ChannelData[i].cc[j] = sspC->ResponseData[offset++];

        setup_request_data->ChannelData[i].cc[j] = '\0'; // NULL TERMINATOR
      }
    } else {
      // Extract the firmware version
      for (i = 0; i < 4; ++i) {
        setup_request_data->FirmwareVersion[i] = sspC->ResponseData[offset++];
      }
      setup_request_data->FirmwareVersion[i] = '\0'; //NULL TERMINATOR

      // Country Code field is obsolete in SSPv6
      offset += 3;
      // Value multiplier field is obsolete in SSPv6
      offset += 3;

      // Extract the number of channels
      setup_request_data->NumberOfChannels = sspC->ResponseData[offset++];

      // The channel values can be ignoredhere
      offset += setup_request_data->NumberOfChannels; // skip past channel values for ssp < v6

      for (i=0; i<setup_request_data->NumberOfChannels; i++) {
        setup_request_data->ChannelData[i].security = sspC->ResponseData[offset++];
      }

      // Extract the multiplier
      setup_request_data->RealValueMultiplier = 0;
      for (i = 0; i < 3; ++i)
        setup_request_data->RealValueMultiplier += ((unsigned long)sspC->ResponseData[offset++] << ((2-i)*8));

      // The protocol version
      setup_request_data->ProtocolVersion = sspC->ResponseData[offset++];

      // for each channel extract the country code
      for (i=0; i<setup_request_data->NumberOfChannels; i++) {
        int j;
        for (j=0; j<3; j++)
          setup_request_data->ChannelData[i].cc[j] = sspC->ResponseData[offset++];

        setup_request_data->ChannelData[i].cc[j] = '\0'; // NULL termination
      }

      // for each channel extract the value
      for (i=0; i<setup_request_data->NumberOfChannels; i++) {
        int j;
        setup_request_data->ChannelData[i].value = 0;
        for (j=0; j<4; j++)
          setup_request_data->ChannelData[i].value += sspC->ResponseData[offset++] << (j*8);
      }
    }
  }
  return resp;
}
Exemplo n.º 30
0
// poll the validator, and extract the responses.
SSP_RESPONSE_ENUM ssp6_poll(SSP_COMMAND *sspC, SSP_POLL_DATA6 *poll_response) {
  SSP_RESPONSE_ENUM resp;
  unsigned char i,j;

  // send the poll command
  sspC->CommandDataLength = 1;
  sspC->CommandData[0] = SSP_CMD_POLL;
  resp = _ssp_return_values(sspC);

  if (resp == SSP_RESPONSE_OK) {
    // if the poll was successful, iterate over all of the response
    poll_response->event_count = 0;
    for (i = 1; i < sspC->ResponseDataLength; ++i) {
      // initialise the event structure
      poll_response->events[poll_response->event_count].event = sspC->ResponseData[i];
      poll_response->events[poll_response->event_count].data1 = 0;
      poll_response->events[poll_response->event_count].data2 = 0;
      poll_response->events[poll_response->event_count].cc[0] = 0;
      poll_response->events[poll_response->event_count].cc[3] = 0;

      switch (sspC->ResponseData[i]) {
        //all these commands have one data byte
      case SSP_POLL_CREDIT:
      case SSP_POLL_READ:
      case SSP_POLL_CLEARED_FROM_FRONT:
      case SSP_POLL_CLEARED_INTO_CASHBOX:
      case SSP_POLL_CALIBRATION_FAIL:
        i++; //move onto the data
        poll_response->events[poll_response->event_count].data1 = sspC->ResponseData[i];
        break;

        //all these commands have 7 data bytes per country;
      case SSP_POLL_DISPENSING:
      case SSP_POLL_DISPENSED:
      case SSP_POLL_JAMMED:
      case SSP_POLL_HALTED:
      case SSP_POLL_FLOATING:
      case SSP_POLL_FLOATED:
      case SSP_POLL_TIMEOUT:
      case SSP_POLL_CASHBOX_PAID:
      case SSP_POLL_COIN_CREDIT:
      case SSP_POLL_SMART_EMPTYING:
      case SSP_POLL_SMART_EMPTIED:
      case SSP_POLL_FRAUD_ATTEMPT: {
        unsigned char event = sspC->ResponseData[i];
        unsigned int countries;
        i++; // move onto the country count;
        countries = (unsigned int)sspC->ResponseData[i];

        // for every country in the response, make a new event structure and store into it
        for (j = 0; j < countries; ++j) {
          int k;
          poll_response->events[poll_response->event_count].event = event;
          poll_response->events[poll_response->event_count].data1 = 0;
          poll_response->events[poll_response->event_count].data2 = 0;
          poll_response->events[poll_response->event_count].cc[3] = '\0';

          for (k = 0; k < 4; ++k) {
            i++; //move through the 4 bytes of data
            poll_response->events[poll_response->event_count].data1 += \
              (((unsigned long)sspC->ResponseData[i]) << (8*i));
          }

          for (k = 0; k < 4; ++k) {
            i++; //move through the 3 bytes of country code
            poll_response->events[poll_response->event_count].cc[k] += sspC->ResponseData[i];
          }

          if (j != countries-1) { // the last time through event_count will be updated elsewhere.
            poll_response->event_count++;
          }
        }
      }
        break;
        // all these commands have 11 data bytes per country;
      case SSP_POLL_INCOMPLETE_PAYOUT:
      case SSP_POLL_INCOMPLETE_FLOAT: {
        unsigned int countries;
        unsigned char event = sspC->ResponseData[i];
        i++; // move onto the country count;
        countries = (unsigned int)sspC->ResponseData[i];
        // for every country in the response, make a new event structure and store into it
        for (j = 0; j < countries; ++j) {
          int k;
          poll_response->events[poll_response->event_count].event = event;
          poll_response->events[poll_response->event_count].data1 = 0;
          poll_response->events[poll_response->event_count].data2 = 0;
          poll_response->events[poll_response->event_count].cc[3] = '\0';

          for (k = 0; k < 4; ++k) {
            i++; //move through the 4 bytes of data
            poll_response->events[poll_response->event_count].data1 += \
              (((unsigned long)sspC->ResponseData[i]) << (8*i));
          }
          for (k = 0; k < 4; ++k) {
            i++; //move through the 4 bytes of data
            poll_response->events[poll_response->event_count].data2 += \
              (((unsigned long)sspC->ResponseData[i]) << (8*i));
          }
          for (k = 0; k < 3; ++k) {
            i++; //move through the 3 bytes of country code
            poll_response->events[poll_response->event_count].cc[k] += sspC->ResponseData[i];
          }

          if (j != countries-1) {// the last time through event_count will be updated elsewhere.
            poll_response->event_count++;
          }
        }
      }
        break;
      default: //every other command has no data bytes
        poll_response->events[poll_response->event_count].data1 = 0;
        poll_response->events[poll_response->event_count].data2 = 0;
        poll_response->events[poll_response->event_count].cc[0] = '\0';
        break;
      }
      poll_response->event_count++;
    }
  }
  return resp;
}