// $Id: GuiMsg.h,v 1.9.4.3 2003/08/19 14:26:42 mdwelsh Exp $ /* tab:4 * "Copyright (c) 2000-2003 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * * Copyright (c) 2002-2003 Intel Corporation * All rights reserved. * * This file is distributed under the terms in the attached INTEL-LICENSE * file. If you do not find these files, copies can be found by writing to * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, * 94704. Attention: Intel License Inquiry. */ /* This file defines the message format for communication between TOSSIM * and TinyViz (the TOSSIM GUI). Communication is bidirectional using * two sockets: EVENT_PORT is used to send events from TOSSIM to * TinyViz; COMMAND_PORT is used to inject commands from TinyViz * into TOSSIM. Every event sent by TOSSIM on EVENT_PORT is * acknowledged by a single-byte ACK before the simulator proceeds. This * allows the GUI to throttle the execution speed of the simulator by * delaying the ACK. Commands sent into TOSSIM by the GUI are not * acknowledged. * * * NOTE NOTE NOTE NOTE NOTE NOTE NOTE * * If you wish to add new command or event types here, there are several * other things you must do. For details, see the README file in * tools/java/net/tinyos/sim. * * NOTE NOTE NOTE NOTE NOTE NOTE NOTE * */ #ifndef GUIMSG_H_INCLUDED #define GUIMSG_H_INCLUDED #include "AM.h" /* Every event/command type has an associated type field. * We use the symbols "AM_" to allow MIG to generate Java types * for each of these structures -- these are not actually * Active Messages! */ enum { /* Events */ AM_DEBUGMSGEVENT, AM_RADIOMSGSENTEVENT, AM_UARTMSGSENTEVENT, AM_ADCDATAREADYEVENT, AM_TOSSIMINITEVENT, /* Commands */ AM_TURNONMOTECOMMAND, AM_TURNOFFMOTECOMMAND, AM_RADIOMSGSENDCOMMAND, AM_UARTMSGSENDCOMMAND, AM_SETLINKPROBCOMMAND, AM_SETADCPORTVALUECOMMAND, }; /* The header structure for commands and events. Following this header * is the message payload, which is 'payLoadLen' bytes in size. */ typedef struct GuiMsg { uint16_t msgType; uint16_t moteID; long long time; uint16_t payLoadLen; } GuiMsg; // This is *NOT* sizeof(GuiMsg) - since alignment constraints // might require additional padding in the structure #define GUI_MSG_HEADER_LENGTH 14 /* Contains a debug message (from the 'dbg()' macro) sent by a mote. */ #define MAX_DEBUG_MSG_LEN 512 typedef struct DebugMsgEvent { char debugMessage[MAX_DEBUG_MSG_LEN]; } DebugMsgEvent; /* Indicates that a radio message was sent by a mote. */ typedef struct RadioMsgSentEvent { TOS_Msg message; } RadioMsgSentEvent; /* Indicates that a UART message was sent by a mote. */ typedef struct UARTMsgSentEvent { TOS_Msg message; } UARTMsgSentEvent; /* Indicates that a UART message was sent by a mote. */ typedef struct ADCDataReadyEvent { uint8_t port; uint16_t data; } ADCDataReadyEvent; /* Sends sim initialization info to TinyViz */ typedef struct TossimInitEvent { int numMotes; } __attribute__((packed)) TossimInitEvent; /* Command to turn a mote on. */ typedef struct TurnOnMoteCommand { } TurnOnMoteCommand; /* Command to turn a mote off. */ typedef struct TurnOffMoteCommand { } TurnOffMoteCommand; /* Command to send a radio message to a mote. */ typedef struct RadioMsgSendCommand { TOS_Msg message; } RadioMsgSendCommand; /* Command to send a UART message to a mote. */ typedef struct UARTMsgSendCommand { TOS_Msg message; } UARTMsgSendCommand; /* Command to set the probability of loss over the radio between to motes */ typedef struct SetLinkProbCommand { uint16_t moteReceiver; uint32_t scaledProb; } SetLinkProbCommand; /* Command to set a mote's adc's port value */ typedef struct SetADCPortValueCommand { uint8_t port; uint16_t value; } SetADCPortValueCommand; #endif