save loops

Dependencies:   mbed

Committer:
mbedalvaro
Date:
Tue Dec 02 04:39:15 2014 +0000
Revision:
0:df6fdd9b99f0
this new version of skinGames will have a function that stops scanning as the laser reaches the same position (i.e., loops) with a certain precision. It is for extracting contours for Takashita project. It can then save on a file or send on osc

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedalvaro 0:df6fdd9b99f0 1 /*
mbedalvaro 0:df6fdd9b99f0 2 * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
mbedalvaro 0:df6fdd9b99f0 3 * Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv>
mbedalvaro 0:df6fdd9b99f0 4 * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands.
mbedalvaro 0:df6fdd9b99f0 5 * All rights reserved.
mbedalvaro 0:df6fdd9b99f0 6 *
mbedalvaro 0:df6fdd9b99f0 7 * Redistribution and use in source and binary forms, with or without modification,
mbedalvaro 0:df6fdd9b99f0 8 * are permitted provided that the following conditions are met:
mbedalvaro 0:df6fdd9b99f0 9 *
mbedalvaro 0:df6fdd9b99f0 10 * 1. Redistributions of source code must retain the above copyright notice,
mbedalvaro 0:df6fdd9b99f0 11 * this list of conditions and the following disclaimer.
mbedalvaro 0:df6fdd9b99f0 12 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbedalvaro 0:df6fdd9b99f0 13 * this list of conditions and the following disclaimer in the documentation
mbedalvaro 0:df6fdd9b99f0 14 * and/or other materials provided with the distribution.
mbedalvaro 0:df6fdd9b99f0 15 * 3. The name of the author may not be used to endorse or promote products
mbedalvaro 0:df6fdd9b99f0 16 * derived from this software without specific prior written permission.
mbedalvaro 0:df6fdd9b99f0 17 *
mbedalvaro 0:df6fdd9b99f0 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
mbedalvaro 0:df6fdd9b99f0 19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
mbedalvaro 0:df6fdd9b99f0 20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
mbedalvaro 0:df6fdd9b99f0 21 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
mbedalvaro 0:df6fdd9b99f0 22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
mbedalvaro 0:df6fdd9b99f0 23 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
mbedalvaro 0:df6fdd9b99f0 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
mbedalvaro 0:df6fdd9b99f0 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
mbedalvaro 0:df6fdd9b99f0 26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
mbedalvaro 0:df6fdd9b99f0 27 * OF SUCH DAMAGE.
mbedalvaro 0:df6fdd9b99f0 28 *
mbedalvaro 0:df6fdd9b99f0 29 * This file is part of the lwIP TCP/IP stack.
mbedalvaro 0:df6fdd9b99f0 30 *
mbedalvaro 0:df6fdd9b99f0 31 * Author: Adam Dunkels <adam@sics.se>
mbedalvaro 0:df6fdd9b99f0 32 *
mbedalvaro 0:df6fdd9b99f0 33 */
mbedalvaro 0:df6fdd9b99f0 34
mbedalvaro 0:df6fdd9b99f0 35 #ifndef __NETIF_ETHARP_H__
mbedalvaro 0:df6fdd9b99f0 36 #define __NETIF_ETHARP_H__
mbedalvaro 0:df6fdd9b99f0 37
mbedalvaro 0:df6fdd9b99f0 38 #include "lwip/opt.h"
mbedalvaro 0:df6fdd9b99f0 39
mbedalvaro 0:df6fdd9b99f0 40 #if LWIP_ARP || LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */
mbedalvaro 0:df6fdd9b99f0 41
mbedalvaro 0:df6fdd9b99f0 42 #include "lwip/pbuf.h"
mbedalvaro 0:df6fdd9b99f0 43 #include "lwip/ip_addr.h"
mbedalvaro 0:df6fdd9b99f0 44 #include "lwip/netif.h"
mbedalvaro 0:df6fdd9b99f0 45 #include "lwip/ip.h"
mbedalvaro 0:df6fdd9b99f0 46
mbedalvaro 0:df6fdd9b99f0 47 #ifdef __cplusplus
mbedalvaro 0:df6fdd9b99f0 48 extern "C" {
mbedalvaro 0:df6fdd9b99f0 49 #endif
mbedalvaro 0:df6fdd9b99f0 50
mbedalvaro 0:df6fdd9b99f0 51 #ifndef ETHARP_HWADDR_LEN
mbedalvaro 0:df6fdd9b99f0 52 #define ETHARP_HWADDR_LEN 6
mbedalvaro 0:df6fdd9b99f0 53 #endif
mbedalvaro 0:df6fdd9b99f0 54
mbedalvaro 0:df6fdd9b99f0 55 #ifdef PACK_STRUCT_USE_INCLUDES
mbedalvaro 0:df6fdd9b99f0 56 # include "arch/bpstruct.h"
mbedalvaro 0:df6fdd9b99f0 57 #endif
mbedalvaro 0:df6fdd9b99f0 58 PACK_STRUCT_BEGIN
mbedalvaro 0:df6fdd9b99f0 59 struct eth_addr {
mbedalvaro 0:df6fdd9b99f0 60 PACK_STRUCT_FIELD(u8_t addr[ETHARP_HWADDR_LEN]);
mbedalvaro 0:df6fdd9b99f0 61 } PACK_STRUCT_STRUCT;
mbedalvaro 0:df6fdd9b99f0 62 PACK_STRUCT_END
mbedalvaro 0:df6fdd9b99f0 63 #ifdef PACK_STRUCT_USE_INCLUDES
mbedalvaro 0:df6fdd9b99f0 64 # include "arch/epstruct.h"
mbedalvaro 0:df6fdd9b99f0 65 #endif
mbedalvaro 0:df6fdd9b99f0 66
mbedalvaro 0:df6fdd9b99f0 67 #ifdef PACK_STRUCT_USE_INCLUDES
mbedalvaro 0:df6fdd9b99f0 68 # include "arch/bpstruct.h"
mbedalvaro 0:df6fdd9b99f0 69 #endif
mbedalvaro 0:df6fdd9b99f0 70 PACK_STRUCT_BEGIN
mbedalvaro 0:df6fdd9b99f0 71 /* Ethernet header */
mbedalvaro 0:df6fdd9b99f0 72 struct eth_hdr {
mbedalvaro 0:df6fdd9b99f0 73 #if ETH_PAD_SIZE
mbedalvaro 0:df6fdd9b99f0 74 PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]);
mbedalvaro 0:df6fdd9b99f0 75 #endif
mbedalvaro 0:df6fdd9b99f0 76 PACK_STRUCT_FIELD(struct eth_addr dest);
mbedalvaro 0:df6fdd9b99f0 77 PACK_STRUCT_FIELD(struct eth_addr src);
mbedalvaro 0:df6fdd9b99f0 78 PACK_STRUCT_FIELD(u16_t type);
mbedalvaro 0:df6fdd9b99f0 79 } PACK_STRUCT_STRUCT;
mbedalvaro 0:df6fdd9b99f0 80 PACK_STRUCT_END
mbedalvaro 0:df6fdd9b99f0 81 #ifdef PACK_STRUCT_USE_INCLUDES
mbedalvaro 0:df6fdd9b99f0 82 # include "arch/epstruct.h"
mbedalvaro 0:df6fdd9b99f0 83 #endif
mbedalvaro 0:df6fdd9b99f0 84
mbedalvaro 0:df6fdd9b99f0 85 #define SIZEOF_ETH_HDR (14 + ETH_PAD_SIZE)
mbedalvaro 0:df6fdd9b99f0 86
mbedalvaro 0:df6fdd9b99f0 87 #if ETHARP_SUPPORT_VLAN
mbedalvaro 0:df6fdd9b99f0 88
mbedalvaro 0:df6fdd9b99f0 89 #ifdef PACK_STRUCT_USE_INCLUDES
mbedalvaro 0:df6fdd9b99f0 90 # include "arch/bpstruct.h"
mbedalvaro 0:df6fdd9b99f0 91 #endif
mbedalvaro 0:df6fdd9b99f0 92 PACK_STRUCT_BEGIN
mbedalvaro 0:df6fdd9b99f0 93 /* VLAN header inserted between ethernet header and payload
mbedalvaro 0:df6fdd9b99f0 94 * if 'type' in ethernet header is ETHTYPE_VLAN.
mbedalvaro 0:df6fdd9b99f0 95 * See IEEE802.Q */
mbedalvaro 0:df6fdd9b99f0 96 struct eth_vlan_hdr {
mbedalvaro 0:df6fdd9b99f0 97 PACK_STRUCT_FIELD(u16_t tpid);
mbedalvaro 0:df6fdd9b99f0 98 PACK_STRUCT_FIELD(u16_t prio_vid);
mbedalvaro 0:df6fdd9b99f0 99 } PACK_STRUCT_STRUCT;
mbedalvaro 0:df6fdd9b99f0 100 PACK_STRUCT_END
mbedalvaro 0:df6fdd9b99f0 101 #ifdef PACK_STRUCT_USE_INCLUDES
mbedalvaro 0:df6fdd9b99f0 102 # include "arch/epstruct.h"
mbedalvaro 0:df6fdd9b99f0 103 #endif
mbedalvaro 0:df6fdd9b99f0 104
mbedalvaro 0:df6fdd9b99f0 105 #define SIZEOF_VLAN_HDR 4
mbedalvaro 0:df6fdd9b99f0 106 #define VLAN_ID(vlan_hdr) (htons((vlan_hdr)->prio_vid) & 0xFFF)
mbedalvaro 0:df6fdd9b99f0 107
mbedalvaro 0:df6fdd9b99f0 108 #endif /* ETHARP_SUPPORT_VLAN */
mbedalvaro 0:df6fdd9b99f0 109
mbedalvaro 0:df6fdd9b99f0 110 #ifdef PACK_STRUCT_USE_INCLUDES
mbedalvaro 0:df6fdd9b99f0 111 # include "arch/bpstruct.h"
mbedalvaro 0:df6fdd9b99f0 112 #endif
mbedalvaro 0:df6fdd9b99f0 113 PACK_STRUCT_BEGIN
mbedalvaro 0:df6fdd9b99f0 114 /* the ARP message, see RFC 826 ("Packet format") */
mbedalvaro 0:df6fdd9b99f0 115 struct etharp_hdr {
mbedalvaro 0:df6fdd9b99f0 116 PACK_STRUCT_FIELD(u16_t hwtype);
mbedalvaro 0:df6fdd9b99f0 117 PACK_STRUCT_FIELD(u16_t proto);
mbedalvaro 0:df6fdd9b99f0 118 PACK_STRUCT_FIELD(u8_t hwlen);
mbedalvaro 0:df6fdd9b99f0 119 PACK_STRUCT_FIELD(u8_t protolen);
mbedalvaro 0:df6fdd9b99f0 120 PACK_STRUCT_FIELD(u16_t opcode);
mbedalvaro 0:df6fdd9b99f0 121 PACK_STRUCT_FIELD(struct eth_addr shwaddr);
mbedalvaro 0:df6fdd9b99f0 122 PACK_STRUCT_FIELD(struct ip_addr2 sipaddr);
mbedalvaro 0:df6fdd9b99f0 123 PACK_STRUCT_FIELD(struct eth_addr dhwaddr);
mbedalvaro 0:df6fdd9b99f0 124 PACK_STRUCT_FIELD(struct ip_addr2 dipaddr);
mbedalvaro 0:df6fdd9b99f0 125 } PACK_STRUCT_STRUCT;
mbedalvaro 0:df6fdd9b99f0 126 PACK_STRUCT_END
mbedalvaro 0:df6fdd9b99f0 127 #ifdef PACK_STRUCT_USE_INCLUDES
mbedalvaro 0:df6fdd9b99f0 128 # include "arch/epstruct.h"
mbedalvaro 0:df6fdd9b99f0 129 #endif
mbedalvaro 0:df6fdd9b99f0 130
mbedalvaro 0:df6fdd9b99f0 131 #define SIZEOF_ETHARP_HDR 28
mbedalvaro 0:df6fdd9b99f0 132 #define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR)
mbedalvaro 0:df6fdd9b99f0 133
mbedalvaro 0:df6fdd9b99f0 134 /* 5 seconds period */
mbedalvaro 0:df6fdd9b99f0 135 #define ARP_TMR_INTERVAL 5000
mbedalvaro 0:df6fdd9b99f0 136
mbedalvaro 0:df6fdd9b99f0 137 #define ETHTYPE_ARP 0x0806
mbedalvaro 0:df6fdd9b99f0 138 #define ETHTYPE_IP 0x0800
mbedalvaro 0:df6fdd9b99f0 139 #define ETHTYPE_VLAN 0x8100
mbedalvaro 0:df6fdd9b99f0 140 #define ETHTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */
mbedalvaro 0:df6fdd9b99f0 141 #define ETHTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */
mbedalvaro 0:df6fdd9b99f0 142
mbedalvaro 0:df6fdd9b99f0 143 /* MEMCPY-like macro to copy to/from struct eth_addr's that are local variables
mbedalvaro 0:df6fdd9b99f0 144 * or known to be 32-bit aligned within the protocol header. */
mbedalvaro 0:df6fdd9b99f0 145 #ifndef ETHADDR32_COPY
mbedalvaro 0:df6fdd9b99f0 146 #define ETHADDR32_COPY(src, dst) SMEMCPY(src, dst, ETHARP_HWADDR_LEN)
mbedalvaro 0:df6fdd9b99f0 147 #endif
mbedalvaro 0:df6fdd9b99f0 148
mbedalvaro 0:df6fdd9b99f0 149 /* MEMCPY-like macro to copy to/from struct eth_addr's that are no local
mbedalvaro 0:df6fdd9b99f0 150 * variables and known to be 16-bit aligned within the protocol header. */
mbedalvaro 0:df6fdd9b99f0 151 #ifndef ETHADDR16_COPY
mbedalvaro 0:df6fdd9b99f0 152 #define ETHADDR16_COPY(src, dst) SMEMCPY(src, dst, ETHARP_HWADDR_LEN)
mbedalvaro 0:df6fdd9b99f0 153 #endif
mbedalvaro 0:df6fdd9b99f0 154
mbedalvaro 0:df6fdd9b99f0 155 #if LWIP_ARP /* don't build if not configured for use in lwipopts.h */
mbedalvaro 0:df6fdd9b99f0 156
mbedalvaro 0:df6fdd9b99f0 157 /* ARP message types (opcodes) */
mbedalvaro 0:df6fdd9b99f0 158 #define ARP_REQUEST 1
mbedalvaro 0:df6fdd9b99f0 159 #define ARP_REPLY 2
mbedalvaro 0:df6fdd9b99f0 160
mbedalvaro 0:df6fdd9b99f0 161 /* Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type)
mbedalvaro 0:df6fdd9b99f0 162 * to a filter function that returns the correct netif when using multiple
mbedalvaro 0:df6fdd9b99f0 163 * netifs on one hardware interface where the netif's low-level receive
mbedalvaro 0:df6fdd9b99f0 164 * routine cannot decide for the correct netif (e.g. when mapping multiple
mbedalvaro 0:df6fdd9b99f0 165 * IP addresses to one hardware interface).
mbedalvaro 0:df6fdd9b99f0 166 */
mbedalvaro 0:df6fdd9b99f0 167 #ifndef LWIP_ARP_FILTER_NETIF
mbedalvaro 0:df6fdd9b99f0 168 #define LWIP_ARP_FILTER_NETIF 0
mbedalvaro 0:df6fdd9b99f0 169 #endif
mbedalvaro 0:df6fdd9b99f0 170
mbedalvaro 0:df6fdd9b99f0 171 #if ARP_QUEUEING
mbedalvaro 0:df6fdd9b99f0 172 /* struct for queueing outgoing packets for unknown address
mbedalvaro 0:df6fdd9b99f0 173 * defined here to be accessed by memp.h
mbedalvaro 0:df6fdd9b99f0 174 */
mbedalvaro 0:df6fdd9b99f0 175 struct etharp_q_entry {
mbedalvaro 0:df6fdd9b99f0 176 struct etharp_q_entry *next;
mbedalvaro 0:df6fdd9b99f0 177 struct pbuf *p;
mbedalvaro 0:df6fdd9b99f0 178 };
mbedalvaro 0:df6fdd9b99f0 179 #endif /* ARP_QUEUEING */
mbedalvaro 0:df6fdd9b99f0 180
mbedalvaro 0:df6fdd9b99f0 181 #define etharp_init() /* Compatibility define, not init needed. */
mbedalvaro 0:df6fdd9b99f0 182 void etharp_tmr(void);
mbedalvaro 0:df6fdd9b99f0 183 s8_t etharp_find_addr(struct netif *netif, ip_addr_t *ipaddr,
mbedalvaro 0:df6fdd9b99f0 184 struct eth_addr **eth_ret, ip_addr_t **ip_ret);
mbedalvaro 0:df6fdd9b99f0 185 err_t etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr);
mbedalvaro 0:df6fdd9b99f0 186 err_t etharp_query(struct netif *netif, ip_addr_t *ipaddr, struct pbuf *q);
mbedalvaro 0:df6fdd9b99f0 187 err_t etharp_request(struct netif *netif, ip_addr_t *ipaddr);
mbedalvaro 0:df6fdd9b99f0 188 /* For Ethernet network interfaces, we might want to send "gratuitous ARP";
mbedalvaro 0:df6fdd9b99f0 189 * this is an ARP packet sent by a node in order to spontaneously cause other
mbedalvaro 0:df6fdd9b99f0 190 * nodes to update an entry in their ARP cache.
mbedalvaro 0:df6fdd9b99f0 191 * From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */
mbedalvaro 0:df6fdd9b99f0 192 #define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr)
mbedalvaro 0:df6fdd9b99f0 193
mbedalvaro 0:df6fdd9b99f0 194 #if ETHARP_SUPPORT_STATIC_ENTRIES
mbedalvaro 0:df6fdd9b99f0 195 err_t etharp_add_static_entry(ip_addr_t *ipaddr, struct eth_addr *ethaddr);
mbedalvaro 0:df6fdd9b99f0 196 err_t etharp_remove_static_entry(ip_addr_t *ipaddr);
mbedalvaro 0:df6fdd9b99f0 197 #endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
mbedalvaro 0:df6fdd9b99f0 198
mbedalvaro 0:df6fdd9b99f0 199 #if LWIP_AUTOIP
mbedalvaro 0:df6fdd9b99f0 200 err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
mbedalvaro 0:df6fdd9b99f0 201 const struct eth_addr *ethdst_addr,
mbedalvaro 0:df6fdd9b99f0 202 const struct eth_addr *hwsrc_addr, const ip_addr_t *ipsrc_addr,
mbedalvaro 0:df6fdd9b99f0 203 const struct eth_addr *hwdst_addr, const ip_addr_t *ipdst_addr,
mbedalvaro 0:df6fdd9b99f0 204 const u16_t opcode);
mbedalvaro 0:df6fdd9b99f0 205 #endif /* LWIP_AUTOIP */
mbedalvaro 0:df6fdd9b99f0 206
mbedalvaro 0:df6fdd9b99f0 207 #endif /* LWIP_ARP */
mbedalvaro 0:df6fdd9b99f0 208
mbedalvaro 0:df6fdd9b99f0 209 err_t ethernet_input(struct pbuf *p, struct netif *netif);
mbedalvaro 0:df6fdd9b99f0 210
mbedalvaro 0:df6fdd9b99f0 211 #define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0)
mbedalvaro 0:df6fdd9b99f0 212
mbedalvaro 0:df6fdd9b99f0 213 extern const struct eth_addr ethbroadcast, ethzero;
mbedalvaro 0:df6fdd9b99f0 214
mbedalvaro 0:df6fdd9b99f0 215 #ifdef __cplusplus
mbedalvaro 0:df6fdd9b99f0 216 }
mbedalvaro 0:df6fdd9b99f0 217 #endif
mbedalvaro 0:df6fdd9b99f0 218
mbedalvaro 0:df6fdd9b99f0 219 #endif /* LWIP_ARP || LWIP_ETHERNET */
mbedalvaro 0:df6fdd9b99f0 220
mbedalvaro 0:df6fdd9b99f0 221 #endif /* __NETIF_ARP_H__ */