/*!-----------------------------------------------------------------------

    L u a _ v s i C o r e F l u s h S i g n a l

	@brief Flush all instances of the specified signal from the data store.

    Lua Interface:

      Input arguments:
        domain - a number indicating what type of data this is (e.g. CAN, etc.).
        key - a number identifying a specific signal in the domain.

      Return values:
        status - the completion status of the operation (0 == successful).

    This function will find the message with the specified domain and key
	This function will find all of the instances of signals with the specified
    domain and key and remove them from the data store.  This call is designed
    to allow users to basically reset all of the data associated with a signal
    so the app can start from a known clean point.

        int vsi_core_flush_signal ( vsi_core_handle handle, domains domain,
                                    offset_t key );

    @param[in] handle - The handle to the VSI core data store.
    @param[in] domain - The domain associated with this message.
    @param[in] key - The key value associated with this message.

	@return 0 on Success
            Anything else is an error code (errno value)

------------------------------------------------------------------------*/
static int Lua_vsiCoreFlushSignal ( lua_State* L )
{
    unsigned int domain = luaL_checkinteger ( L, 1 );
    unsigned int key    = luaL_checkinteger ( L, 2 );

    int status = vsi_core_flush_signal ( domain, key );

    lua_pushinteger ( L, status );

    return 1;
}
Example #2
0
/*!-----------------------------------------------------------------------

    m a i n

    @brief The main entry point for this compilation unit.

    This function will read and remove a single message from the shared memory segment
    as specified by the user.

    The "domain" will default to "CAN" if not specified by the caller and the
    "key" value will default to 0.

    Note that the "body" data will be read as 8 bytes of data and interpreted
    as a numeric value and as an ASCII string on output.

    @return  0 - This function completed without errors
    @return !0 - The error code that was encountered

------------------------------------------------------------------------*/
int main ( int argc, char* const argv[] )
{
    //
    //  The following locale settings will allow the use of the comma
    //  "thousands" separator format specifier to be used.  e.g. "10000"
    //  will print as "10,000" (using the %'u spec.).
    //
    setlocale ( LC_ALL, "");

    //
    //  Parse any command line options the user may have supplied.
    //
    signal_t signal     = 0;
    domain_t domain  = DOMAIN_CAN;
    int status            = 0;
    char ch               = 0;

    while ( ( ch = getopt ( argc, argv, "d:s:nh?" ) ) != -1 )
    {
        switch ( ch )
        {
          //
          //  Get the requested domain value.
          //
          case 'd':
            domain = atol ( optarg );
            LOG ( "Using domain value[%'d]\n", domain );
            break;

          //
          //  Get the requested key value.
          //
          case 's':
            signal = atol ( optarg );
            LOG ( "Using signal value[%'d]\n", signal );
            break;

          //
          //  Display the help message.
          //
          case 'h':
          case '?':
          default:
            usage ( argv[0] );
            exit ( 0 );
        }
    }
    //
    //  If the user supplied any arguments not parsed above, they are not
    //  valid arguments so complain and quit.
    //
    argc -= optind;
    if ( argc != 0 )
    {
        printf ( "Invalid parameters[s] encountered: %s\n", argv[argc] );
        usage ( argv[0] );
        exit (255);
    }
    //
    //  Open the shared memory file.
    //
    //  Note that if the shared memory segment does not already exist, this
    //  call will create it.
    //
    vsi_initialize ( false );

    //
    //  Go flush all messages with the given domain and key.
    //
    LOG ( "  Flushing domain: %'d\n  key...: %'d\n", domain, signal );

    status = vsi_core_flush_signal ( domain, signal );
    if ( status != 0 )
    {
        printf ( "----> Error %d[%s] returned\n", status, strerror(status) );
    }
    //
    //  Close our shared memory segment and exit.
    //
    vsi_core_close();

    //
    //  Return a good completion code to the caller.
    //
    return 0;
}