Exemple #1
0
void t7(int pi)
{
   int c, oc, id;

   printf("Watchdog tests.\n");

   /* type of edge shouldn't matter for watchdogs */
   id = callback(pi, GPIO, FALLING_EDGE, t7cbf);

   set_watchdog(pi, GPIO, 50); /* 50 ms, 20 per second */
   time_sleep(0.5);
   oc = t7_count;
   time_sleep(2);
   c = t7_count - oc;
   CHECK(7, 1, c, 39, 5, "set watchdog on count");

   set_watchdog(pi, GPIO, 0); /* 0 switches watchdog off */
   time_sleep(0.5);
   oc = t7_count;
   time_sleep(2);
   c = t7_count - oc;
   CHECK(7, 2, c, 0, 1, "set watchdog off count");

   callback_cancel(id);
}
Exemple #2
0
void t7()
{
   int c, oc;

   printf("Watchdog tests.\n");

   /* type of edge shouldn't matter for watchdogs */
   callback(GPIO, FALLING_EDGE, t7cbf);

   set_watchdog(GPIO, 10); /* 10 ms, 100 per second */
   time_sleep(0.5);
   oc = t7_count;
   time_sleep(2);
   c = t7_count - oc;
   CHECK(7, 1, c, 200, 1, "set watchdog on count");

   set_watchdog(GPIO, 0); /* 0 switches watchdog off */
   time_sleep(0.5);
   oc = t7_count;
   time_sleep(2);
   c = t7_count - oc;
   CHECK(7, 2, c, 0, 1, "set watchdog off count");
}
/************************************************************
 * Assuming that the RESERVE phases were successful, the next
 * stage is indicated by the action value ACTION. This is used
 * to actually implement the set operation. However, this must
 * either be done into temporary (persistent) storage, or the
 * previous value stored similarly, in case any of the subsequent
 * ACTION calls fail.
 *
 * In your case, changes should be made to row_ctx. A copy of
 * the original row is in undo_ctx.
 */
void
saHpiWatchdogTable_set_action(netsnmp_request_group * rg)
{
    netsnmp_variable_list *var;
    saHpiWatchdogTable_context *row_ctx =
        (saHpiWatchdogTable_context *) rg->existing_row;
    /*    saHpiWatchdogTable_context *undo_ctx =
	  (saHpiWatchdogTable_context *) rg->undo_info;*/
    netsnmp_request_group_item *current;

    DEBUGMSGTL((AGENT,"saHpiWatchdogTable_set_action. Entry\n"));
    /*
     * TODO: loop through columns, copy varbind values
     * to context structure for the row.
     */
    for (current = rg->list; current; current = current->next) {

        var = current->ri->requestvb;

        switch (current->tri->colnum) {

        case COLUMN_SAHPIWATCHDOGLOG:
            /** TruthValue = ASN_INTEGER */
            row_ctx->saHpiWatchdogLog = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGRUNNING:
            /** TruthValue = ASN_INTEGER */
            row_ctx->saHpiWatchdogRunning = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGTIMERUSE:
            /** INTEGER = ASN_INTEGER */
            row_ctx->saHpiWatchdogTimerUse = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGTIMERACTION:
            /** INTEGER = ASN_INTEGER */
            row_ctx->saHpiWatchdogTimerAction = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGPRETIMERINTERRUPT:
            /** INTEGER = ASN_INTEGER */
            row_ctx->saHpiWatchdogPretimerInterrupt = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGPRETIMEOUTINTERVAL:
            /** UNSIGNED32 = ASN_UNSIGNED */
            row_ctx->saHpiWatchdogPreTimeoutInterval = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGTIMERUSEEXPFLAGS:
            /** UNSIGNED32 = ASN_UNSIGNED */
            row_ctx->saHpiWatchdogTimerUseExpFlags = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGTIMERINITIALCOUNT:
            /** UNSIGNED32 = ASN_UNSIGNED */
            row_ctx->saHpiWatchdogTimerInitialCount = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGTIMERPRESENTCOUNT:
            /** UNSIGNED32 = ASN_UNSIGNED */
            row_ctx->saHpiWatchdogTimerPresentCount = *var->val.integer;
            break;       

        default:/** We shouldn't get here */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
        }

	DEBUGMSGTL((AGENT,"saHpiWatchdogTable_set_action: Calling 'set_watchdog'\n"));
	if (set_watchdog(row_ctx) != AGENT_ERR_NOERROR) {
	  netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri,
					 SNMP_ERR_GENERR);
	}
    }

    DEBUGMSGTL((AGENT,"saHpiWatchdogTable_set_action. Exit\n"));   
   
}
/************************************************************
 * Assuming that the RESERVE phases were successful, the next
 * stage is indicated by the action value ACTION. This is used
 * to actually implement the set operation. However, this must
 * either be done into temporary (persistent) storage, or the
 * previous value stored similarly, in case any of the subsequent
 * ACTION calls fail.
 *
 * In your case, changes should be made to row_ctx. A copy of
 * the original row is in undo_ctx.
 */
void
saHpiWatchdogTable_set_action (netsnmp_request_group * rg)
{
  netsnmp_variable_list *var;
  saHpiWatchdogTable_context *row_ctx =
    (saHpiWatchdogTable_context *) rg->existing_row;

  netsnmp_request_group_item *current;
  int rc = SNMP_ERR_NOERROR;

  DEBUGMSGTL ((AGENT, "saHpiWatchdogTable_set_action. Entry\n"));

  for (current = rg->list; current; current = current->next)
    {

      var = current->ri->requestvb;

      switch (current->tri->colnum)
	{

	case COLUMN_SAHPIWATCHDOGLOG:
	    /** TruthValue = ASN_INTEGER */
	  row_ctx->saHpiWatchdogLog = *var->val.integer;
	  break;

	case COLUMN_SAHPIWATCHDOGRUNNING:
	    /** TruthValue = ASN_INTEGER */
	  row_ctx->saHpiWatchdogRunning = *var->val.integer;
	  break;

	case COLUMN_SAHPIWATCHDOGTIMERUSE:
	    /** INTEGER = ASN_INTEGER */
	  row_ctx->saHpiWatchdogTimerUse = *var->val.integer;
	  break;

	case COLUMN_SAHPIWATCHDOGTIMERACTION:
	    /** INTEGER = ASN_INTEGER */
	  row_ctx->saHpiWatchdogTimerAction = *var->val.integer;
	  break;

	case COLUMN_SAHPIWATCHDOGPRETIMERINTERRUPT:
	    /** INTEGER = ASN_INTEGER */
	  row_ctx->saHpiWatchdogPretimerInterrupt = *var->val.integer;
	  break;

	case COLUMN_SAHPIWATCHDOGPRETIMEOUTINTERVAL:
	    /** UNSIGNED32 = ASN_UNSIGNED */
	  row_ctx->saHpiWatchdogPreTimeoutInterval = *var->val.integer;
	  break;

	case COLUMN_SAHPIWATCHDOGTIMERUSEEXPFLAGS:
	    /** UNSIGNED32 = ASN_UNSIGNED */
	  row_ctx->saHpiWatchdogTimerUseExpFlags = *var->val.integer;
	  break;

	case COLUMN_SAHPIWATCHDOGTIMERINITIALCOUNT:
	    /** UNSIGNED32 = ASN_UNSIGNED */
	  row_ctx->saHpiWatchdogTimerInitialCount = *var->val.integer;
	  break;

	case COLUMN_SAHPIWATCHDOGTIMERPRESENTCOUNT:
	    /** UNSIGNED32 = ASN_UNSIGNED */
	  row_ctx->saHpiWatchdogTimerPresentCount = *var->val.integer;
	  break;

	case COLUMN_SAHPIWATCHDOGTIMERRESET:
	    /** TruthValue = ASN_INTEGER */
	  row_ctx->saHpiWatchdogTimerReset = *var->val.integer;

	  // Set it only when set to MIB_TRUE
	  if (row_ctx->saHpiWatchdogTimerReset == MIB_TRUE)
	    {
	      if (set_timer_reset (row_ctx) != AGENT_ERR_NOERROR)
		rc = SNMP_ERR_GENERR;
	    }
	  break;
	default:
		/** We shouldn't get here */
	  netsnmp_assert (0);  /** why wasn't this caught in reserve1? */
	}

      if (current->tri->colnum != COLUMN_SAHPIWATCHDOGTIMERRESET)
	{
	  DEBUGMSGTL ((AGENT,
		       "saHpiWatchdogTable_set_action: Calling 'set_watchdog'\n"));
	  if (set_watchdog (row_ctx) != AGENT_ERR_NOERROR)
	    {
	      rc = SNMP_ERR_GENERR;
	    }
	}

      if (rc)
	netsnmp_set_mode_request_error (MODE_SET_BEGIN, current->ri, rc);


    }

  DEBUGMSGTL ((AGENT, "saHpiWatchdogTable_set_action. Exit\n"));

}