Example #1
0
//******************************************************************************************************************************************
// Main loop[
//******************************************************************************************************************************************
void loop()
{
  start();
  unsigned int  data_hex = 0x11;
  serial_8(data_hex);
  handover();
  read_kma210();

  takeover();
  stop();
  Serial.print(result, HEX);
}
void check_mon_msg(char *mon_msg) {
    MS_Mon_Msg *msg = (MS_Mon_Msg *) mon_msg;

    switch (msg->type) {
    case MS_MsgType_Close:    // process close notification
        myprintf("Close notice received from %s.\n",
                 msg->u.close.process_name);
        if (strcmp(gname, msg->u.close.process_name) != 0) {
            gopen_count--;
            myprintf("Disconnecting from client\n");
        }
        break;
    case MS_MsgType_NodeDown: // node is down notification
    case MS_MsgType_NodeUp:   // node is up notification
        myprintf("Node Up/Down notices not currently supported.\n");
        break;
    case MS_MsgType_Open:     // process open notification
        myprintf("Open notice received from %s.\n",
                 msg->u.open.target_process_name);
        if (strcmp(gname, msg->u.open.target_process_name) == 0) {
            gpeer_nid = msg->u.open.nid;
            gpeer_pid = msg->u.open.pid;
            myprintf("peer p-id=%d/%d\n", gpeer_nid, gpeer_pid);
            mypairinfo(false);
        }
        break;
    case MS_MsgType_ProcessDeath: // process death notification
        myprintf("ProcessDeath notice received from p-id=%d/%d.\n",
                msg->u.death.nid, msg->u.death.pid);
        if ((gpeer_nid == msg->u.death.nid) &&
            (gpeer_pid == msg->u.death.pid))
            gtakeover = takeover();
        break;
    case MS_MsgType_Shutdown: // shutdown notification
        myprintf("Shutdown notice received.\n");
        break;
    default:
        myprintf("Invalid notice message type received.\n");
    }
}