Program the control the fischertechnik robo interface or intelligent interface via tcp socket or via a java gui.

Dependencies:   mbed ConfigFile

Committer:
networker
Date:
Fri Dec 31 14:01:14 2010 +0000
Revision:
0:7f26f0680202
initial release: comprises ftlib (no usb), ft-over-ip socket server, and the http server (the html page and java jar I still have to publish somewhere)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
networker 0:7f26f0680202 1 /*****************************************************************************
networker 0:7f26f0680202 2 * fsm.h - Network Control Protocol Finite State Machine header file.
networker 0:7f26f0680202 3 *
networker 0:7f26f0680202 4 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
networker 0:7f26f0680202 5 * Copyright (c) 1997 Global Election Systems Inc.
networker 0:7f26f0680202 6 *
networker 0:7f26f0680202 7 * The authors hereby grant permission to use, copy, modify, distribute,
networker 0:7f26f0680202 8 * and license this software and its documentation for any purpose, provided
networker 0:7f26f0680202 9 * that existing copyright notices are retained in all copies and that this
networker 0:7f26f0680202 10 * notice and the following disclaimer are included verbatim in any
networker 0:7f26f0680202 11 * distributions. No written agreement, license, or royalty fee is required
networker 0:7f26f0680202 12 * for any of the authorized uses.
networker 0:7f26f0680202 13 *
networker 0:7f26f0680202 14 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
networker 0:7f26f0680202 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
networker 0:7f26f0680202 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
networker 0:7f26f0680202 17 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
networker 0:7f26f0680202 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
networker 0:7f26f0680202 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
networker 0:7f26f0680202 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
networker 0:7f26f0680202 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
networker 0:7f26f0680202 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
networker 0:7f26f0680202 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
networker 0:7f26f0680202 24 *
networker 0:7f26f0680202 25 ******************************************************************************
networker 0:7f26f0680202 26 * REVISION HISTORY
networker 0:7f26f0680202 27 *
networker 0:7f26f0680202 28 * 03-01-01 Marc Boucher <marc@mbsi.ca>
networker 0:7f26f0680202 29 * Ported to lwIP.
networker 0:7f26f0680202 30 * 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
networker 0:7f26f0680202 31 * Original based on BSD code.
networker 0:7f26f0680202 32 *****************************************************************************/
networker 0:7f26f0680202 33 /*
networker 0:7f26f0680202 34 * fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
networker 0:7f26f0680202 35 *
networker 0:7f26f0680202 36 * Copyright (c) 1989 Carnegie Mellon University.
networker 0:7f26f0680202 37 * All rights reserved.
networker 0:7f26f0680202 38 *
networker 0:7f26f0680202 39 * Redistribution and use in source and binary forms are permitted
networker 0:7f26f0680202 40 * provided that the above copyright notice and this paragraph are
networker 0:7f26f0680202 41 * duplicated in all such forms and that any documentation,
networker 0:7f26f0680202 42 * advertising materials, and other materials related to such
networker 0:7f26f0680202 43 * distribution and use acknowledge that the software was developed
networker 0:7f26f0680202 44 * by Carnegie Mellon University. The name of the
networker 0:7f26f0680202 45 * University may not be used to endorse or promote products derived
networker 0:7f26f0680202 46 * from this software without specific prior written permission.
networker 0:7f26f0680202 47 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
networker 0:7f26f0680202 48 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
networker 0:7f26f0680202 49 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
networker 0:7f26f0680202 50 *
networker 0:7f26f0680202 51 * $Id: fsm.h,v 1.5 2009/12/31 17:08:08 goldsimon Exp $
networker 0:7f26f0680202 52 */
networker 0:7f26f0680202 53
networker 0:7f26f0680202 54 #ifndef FSM_H
networker 0:7f26f0680202 55 #define FSM_H
networker 0:7f26f0680202 56
networker 0:7f26f0680202 57 /*
networker 0:7f26f0680202 58 * LCP Packet header = Code, id, length.
networker 0:7f26f0680202 59 */
networker 0:7f26f0680202 60 #define HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short))
networker 0:7f26f0680202 61
networker 0:7f26f0680202 62
networker 0:7f26f0680202 63 /*
networker 0:7f26f0680202 64 * CP (LCP, IPCP, etc.) codes.
networker 0:7f26f0680202 65 */
networker 0:7f26f0680202 66 #define CONFREQ 1 /* Configuration Request */
networker 0:7f26f0680202 67 #define CONFACK 2 /* Configuration Ack */
networker 0:7f26f0680202 68 #define CONFNAK 3 /* Configuration Nak */
networker 0:7f26f0680202 69 #define CONFREJ 4 /* Configuration Reject */
networker 0:7f26f0680202 70 #define TERMREQ 5 /* Termination Request */
networker 0:7f26f0680202 71 #define TERMACK 6 /* Termination Ack */
networker 0:7f26f0680202 72 #define CODEREJ 7 /* Code Reject */
networker 0:7f26f0680202 73
networker 0:7f26f0680202 74
networker 0:7f26f0680202 75 /*
networker 0:7f26f0680202 76 * Each FSM is described by an fsm structure and fsm callbacks.
networker 0:7f26f0680202 77 */
networker 0:7f26f0680202 78 typedef struct fsm {
networker 0:7f26f0680202 79 int unit; /* Interface unit number */
networker 0:7f26f0680202 80 u_short protocol; /* Data Link Layer Protocol field value */
networker 0:7f26f0680202 81 int state; /* State */
networker 0:7f26f0680202 82 int flags; /* Contains option bits */
networker 0:7f26f0680202 83 u_char id; /* Current id */
networker 0:7f26f0680202 84 u_char reqid; /* Current request id */
networker 0:7f26f0680202 85 u_char seen_ack; /* Have received valid Ack/Nak/Rej to Req */
networker 0:7f26f0680202 86 int timeouttime; /* Timeout time in milliseconds */
networker 0:7f26f0680202 87 int maxconfreqtransmits; /* Maximum Configure-Request transmissions */
networker 0:7f26f0680202 88 int retransmits; /* Number of retransmissions left */
networker 0:7f26f0680202 89 int maxtermtransmits; /* Maximum Terminate-Request transmissions */
networker 0:7f26f0680202 90 int nakloops; /* Number of nak loops since last ack */
networker 0:7f26f0680202 91 int maxnakloops; /* Maximum number of nak loops tolerated */
networker 0:7f26f0680202 92 struct fsm_callbacks* callbacks; /* Callback routines */
networker 0:7f26f0680202 93 char* term_reason; /* Reason for closing protocol */
networker 0:7f26f0680202 94 int term_reason_len; /* Length of term_reason */
networker 0:7f26f0680202 95 } fsm;
networker 0:7f26f0680202 96
networker 0:7f26f0680202 97
networker 0:7f26f0680202 98 typedef struct fsm_callbacks {
networker 0:7f26f0680202 99 void (*resetci)(fsm*); /* Reset our Configuration Information */
networker 0:7f26f0680202 100 int (*cilen)(fsm*); /* Length of our Configuration Information */
networker 0:7f26f0680202 101 void (*addci)(fsm*, u_char*, int*); /* Add our Configuration Information */
networker 0:7f26f0680202 102 int (*ackci)(fsm*, u_char*, int); /* ACK our Configuration Information */
networker 0:7f26f0680202 103 int (*nakci)(fsm*, u_char*, int); /* NAK our Configuration Information */
networker 0:7f26f0680202 104 int (*rejci)(fsm*, u_char*, int); /* Reject our Configuration Information */
networker 0:7f26f0680202 105 int (*reqci)(fsm*, u_char*, int*, int); /* Request peer's Configuration Information */
networker 0:7f26f0680202 106 void (*up)(fsm*); /* Called when fsm reaches LS_OPENED state */
networker 0:7f26f0680202 107 void (*down)(fsm*); /* Called when fsm leaves LS_OPENED state */
networker 0:7f26f0680202 108 void (*starting)(fsm*); /* Called when we want the lower layer */
networker 0:7f26f0680202 109 void (*finished)(fsm*); /* Called when we don't want the lower layer */
networker 0:7f26f0680202 110 void (*protreject)(int); /* Called when Protocol-Reject received */
networker 0:7f26f0680202 111 void (*retransmit)(fsm*); /* Retransmission is necessary */
networker 0:7f26f0680202 112 int (*extcode)(fsm*, int, u_char, u_char*, int); /* Called when unknown code received */
networker 0:7f26f0680202 113 char *proto_name; /* String name for protocol (for messages) */
networker 0:7f26f0680202 114 } fsm_callbacks;
networker 0:7f26f0680202 115
networker 0:7f26f0680202 116
networker 0:7f26f0680202 117 /*
networker 0:7f26f0680202 118 * Link states.
networker 0:7f26f0680202 119 */
networker 0:7f26f0680202 120 #define LS_INITIAL 0 /* Down, hasn't been opened */
networker 0:7f26f0680202 121 #define LS_STARTING 1 /* Down, been opened */
networker 0:7f26f0680202 122 #define LS_CLOSED 2 /* Up, hasn't been opened */
networker 0:7f26f0680202 123 #define LS_STOPPED 3 /* Open, waiting for down event */
networker 0:7f26f0680202 124 #define LS_CLOSING 4 /* Terminating the connection, not open */
networker 0:7f26f0680202 125 #define LS_STOPPING 5 /* Terminating, but open */
networker 0:7f26f0680202 126 #define LS_REQSENT 6 /* We've sent a Config Request */
networker 0:7f26f0680202 127 #define LS_ACKRCVD 7 /* We've received a Config Ack */
networker 0:7f26f0680202 128 #define LS_ACKSENT 8 /* We've sent a Config Ack */
networker 0:7f26f0680202 129 #define LS_OPENED 9 /* Connection available */
networker 0:7f26f0680202 130
networker 0:7f26f0680202 131 /*
networker 0:7f26f0680202 132 * Flags - indicate options controlling FSM operation
networker 0:7f26f0680202 133 */
networker 0:7f26f0680202 134 #define OPT_PASSIVE 1 /* Don't die if we don't get a response */
networker 0:7f26f0680202 135 #define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */
networker 0:7f26f0680202 136 #define OPT_SILENT 4 /* Wait for peer to speak first */
networker 0:7f26f0680202 137
networker 0:7f26f0680202 138
networker 0:7f26f0680202 139 /*
networker 0:7f26f0680202 140 * Prototypes
networker 0:7f26f0680202 141 */
networker 0:7f26f0680202 142 void fsm_init (fsm*);
networker 0:7f26f0680202 143 void fsm_lowerup (fsm*);
networker 0:7f26f0680202 144 void fsm_lowerdown (fsm*);
networker 0:7f26f0680202 145 void fsm_open (fsm*);
networker 0:7f26f0680202 146 void fsm_close (fsm*, char*);
networker 0:7f26f0680202 147 void fsm_input (fsm*, u_char*, int);
networker 0:7f26f0680202 148 void fsm_protreject (fsm*);
networker 0:7f26f0680202 149 void fsm_sdata (fsm*, u_char, u_char, u_char*, int);
networker 0:7f26f0680202 150
networker 0:7f26f0680202 151
networker 0:7f26f0680202 152 /*
networker 0:7f26f0680202 153 * Variables
networker 0:7f26f0680202 154 */
networker 0:7f26f0680202 155 extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */
networker 0:7f26f0680202 156
networker 0:7f26f0680202 157 #endif /* FSM_H */