ipcam_packet.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 * Software License Agreement (BSD License)
00003 *
00004 *  Copyright (c) 2009, 2010 Willow Garage, Inc.
00005 *  All rights reserved.
00006 *
00007 *  Redistribution and use in source and binary forms, with or without
00008 *  modification, are permitted provided that the following conditions
00009 *  are met:
00010 *
00011 *   * Redistributions of source code must retain the above copyright
00012 *     notice, this list of conditions and the following disclaimer.
00013 *   * Redistributions in binary form must reproduce the above
00014 *     copyright notice, this list of conditions and the following
00015 *     disclaimer in the documentation and/or other materials provided
00016 *     with the distribution.
00017 *   * Neither the name of the Willow Garage nor the names of its
00018 *     contributors may be used to endorse or promote products derived
00019 *     from this software without specific prior written permission.
00020 *
00021 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 *  POSSIBILITY OF SUCH DAMAGE.
00033 *********************************************************************/
00034 
00040 #ifndef _IPCAM_PACKET_H_
00041 #define _IPCAM_PACKET_H_
00042 
00043 #include "build.h"
00044 
00045 #ifdef DEVICE_BUILD
00046 #warning Building for DEVICE
00047 
00048 #include "ipcam.h"
00049 #include "ipcam_network.h"
00050 #include "ipcam_flash.h"
00051 
00052 //Make sure that LIBRARY_BUILD isn't also defined (only one build type should be defined)
00053 #ifdef LIBRARY_BUILD
00054 #error Multiple builds defined
00055 #endif
00056 
00057 #endif //DEVICE_BUILD
00058 
00059 #define FLASH_MAX_PAGENO 4095
00060 #define FLASH_PAGE_SIZE 264
00061 
00062 #define FLASH_NAME_PAGENO FLASH_MAX_PAGENO
00063 #define FLASH_CALIBRATION_PAGENO (FLASH_MAX_PAGENO - 2)
00064 #define CAMERA_NAME_LEN 40
00065 
00066 #ifdef LIBRARY_BUILD
00067 //#warning Building for LIBRARY
00068 
00069 #include <sys/socket.h>
00070 #include <netinet/in.h>
00071 #include <arpa/inet.h>
00072 
00073 // Simple typedefs for basic network types. These are defined in ipcam_network.h on the camera.
00074 typedef uint32_t IPAddress;
00075 typedef uint8_t MACAddress[6];
00076 typedef uint16_t UDPPort;
00077 
00078 typedef struct {
00079     MACAddress mac;
00080     IPAddress addr;
00081     UDPPort port;
00082 } NetHost;
00083 
00084 //Make sure that DEVICE_BUILD isn't also defined (only one build type should be defined)
00085 #ifdef DEVICE_BUILD
00086 #error Multiple builds defined
00087 #endif
00088 
00089 #endif //LIBRARY_BUILD
00090 
00094 #define WG_MAGIC_NO 0x00DEAF42UL
00095 
00101 #define WG_CAMCMD_PORT 1627
00102 
00109 #define PKTT_DISCOVER      0
00110 #define PKTT_CONFIGURE     1
00111 #define PKTT_VIDSTART      2
00112 #define PKTT_VIDSTOP       3
00113 #define PKTT_RESET         4
00114 #define PKTT_TIMEREQ       5
00115 #define PKTT_FLASHREAD     6
00116 #define PKTT_FLASHWRITE    7
00117 #define PKTT_TRIGCTRL      8
00118 #define PKTT_SENSORRD      9
00119 #define PKTT_SENSORWR      10
00120 #define PKTT_SENSORSEL     11
00121 #define PKTT_IMGRMODE      12
00122 #define PKTT_IMGRSETRES    13
00123 #define PKTT_SYSCONFIG     14
00124 #define PKTT_RECONFIG_FPGA 15
00125 #define PKT_MAX_ID PKTT_RECONFIG_FPGA
00126 
00127 #define PKTT_ANNOUNCE   0x80
00128 #define PKTT_TIMEREPLY  0x81
00129 #define PKTT_STATUS     0x82
00130 #define PKTT_FLASHDATA  0x83
00131 #define PKTT_SENSORDATA 0x84
00132 
00139  #if CAMERA_NAME_LEN != 40
00140  #error CAMERA_NAME_LEN should be 40.
00141  #endif
00142 
00143  typedef struct PACKED_ATTRIBUTE {
00144     char cam_name[CAMERA_NAME_LEN];  
00145     IPAddress cam_addr;                 
00146     uint16_t checksum;               
00147  } IdentityFlashPage;
00148 
00154 typedef struct PACKED_ATTRIBUTE {
00155     uint32_t magic_no;      
00156     uint32_t type;          
00157     char hrt[16];           
00158     NetHost reply_to;       
00159 } PacketGeneric;
00160 
00161 #ifdef DEVICE_BUILD  // The host uses the Linux network stack so doesn't require this section
00162 
00167 typedef struct PACKED_ATTRIBUTE {
00168     EMACHeader emacHdr;
00169     IPHeader ipHdr;
00170     UDPHeader udpHdr;
00171 } NetHeader;
00172 
00173 
00182 typedef struct PACKED_ATTRIBUTE {
00183     NetHeader hdr;
00184     PacketGeneric gPkt;
00185 } GenericFrame;
00186 #endif //DEVICE_BUILD
00187 
00200 typedef struct PACKED_ATTRIBUTE {
00202     PacketGeneric hdr;
00203 
00205     IPAddress ip_addr;
00206 
00207 } PacketDiscover;
00208 
00229 typedef struct PACKED_ATTRIBUTE {
00231     PacketGeneric hdr;
00232 
00234     uint32_t product_id;        
00235     uint32_t ser_no;            
00236 
00238     uint32_t ip_addr;           
00239 
00240 } PacketConfigure;
00241 
00242 
00258 typedef struct PACKED_ATTRIBUTE {
00260     PacketGeneric hdr;
00261 
00263     NetHost receiver;           
00264 } PacketVidStart;
00265 
00281 typedef struct PACKED_ATTRIBUTE { PacketGeneric hdr; } PacketVidStop;
00282 
00298 typedef struct PACKED_ATTRIBUTE { PacketGeneric hdr; } PacketReset;
00299 
00316 typedef struct PACKED_ATTRIBUTE { PacketGeneric hdr; } PacketTimeRequest;
00317 
00344 typedef struct PACKED_ATTRIBUTE {
00346     PacketGeneric hdr;
00347 
00349     uint32_t address;
00350 } PacketFlashRequest;
00351 
00371 typedef struct PACKED_ATTRIBUTE {
00373     PacketGeneric hdr;
00374 
00375     uint32_t address;                       
00376     uint8_t data[FLASH_PAGE_SIZE];          
00377 } PacketFlashPayload;
00378 
00396 typedef struct PACKED_ATTRIBUTE {
00398     PacketGeneric hdr;
00399 
00401     uint32_t trig_state;
00402 } PacketTrigControl;
00403 
00420 typedef struct PACKED_ATTRIBUTE {
00422     PacketGeneric hdr;
00423 
00425     uint8_t address;
00426 } PacketSensorRequest;
00427 
00446 typedef struct PACKED_ATTRIBUTE {
00448     PacketGeneric hdr;
00449 
00450     uint8_t address;            
00451     uint16_t data;              
00452 } PacketSensorData;
00453 
00470 typedef struct PACKED_ATTRIBUTE {
00472     PacketGeneric hdr;
00473 
00474     uint8_t index;          
00475     uint32_t address;       
00476 } PacketSensorSelect;
00477 
00491 typedef struct PACKED_ATTRIBUTE {
00493     PacketGeneric hdr;
00494 
00495     uint32_t mode;          
00496 } PacketImagerMode;
00497 
00498 
00499 
00516 typedef struct PACKED_ATTRIBUTE {
00518     PacketGeneric hdr;
00519 
00520     uint16_t horizontal;        
00521     uint16_t vertical;          
00522 } PacketImagerSetRes;
00523 
00540 typedef struct PACKED_ATTRIBUTE {
00542     PacketGeneric hdr;
00543 
00544     MACAddress mac;
00545     uint32_t serial;
00546 } PacketSysConfig;
00547 
00563 typedef struct PACKED_ATTRIBUTE { PacketGeneric hdr; } PacketReconfigureFPGA;
00564 
00569 #define PKT_STATUST_OK      0           ///< Command completed successfully
00570 #define PKT_STATUST_ERROR   1           ///< Command could not be completed. See status_code for details
00571 
00577 #define PKT_ERROR_TIMEOUT   0           ///< No valid response was received during the allotted interval
00578 #define PKT_ERROR_SYSERR    1           ///< An internal system error occurred
00579 #define PKT_ERROR_INVALID   2           ///< Packet is not valid in this mode
00580 
00587 typedef struct PACKED_ATTRIBUTE {
00589     PacketGeneric hdr;
00590 
00591     uint32_t status_type;               
00592     uint32_t status_code;               
00593 } PacketStatus;
00594 
00595 
00608 typedef struct PACKED_ATTRIBUTE {
00610     PacketGeneric hdr;
00611 
00612     uint32_t ticks_hi;              
00613     uint32_t ticks_lo;              
00614 
00615     uint32_t ticks_per_sec;         
00616 } PacketTimer;
00617 
00622 typedef struct PACKED_ATTRIBUTE {
00624     PacketGeneric hdr;
00625 
00627     MACAddress mac;                 
00628     uint32_t product_id;            
00629     uint32_t ser_no;                
00630     char product_name[40];          
00631     char camera_name[40];           
00632     IPAddress camera_ip;            
00633 
00640     uint32_t hw_version;
00641 
00648     uint32_t fw_version;
00649 
00650     struct in_addr prev_host;       
00651 
00652 } PacketAnnounce;
00653 
00654 
00656 #define IMAGER_MAGICLINE_MASK 0xFFF0
00657 
00659 #define IMAGER_LINENO_EOF 0xFFFF
00660 
00662 #define IMAGER_LINENO_ERR 0xFFFE
00663 
00665 #define IMAGER_LINENO_OVF 0xFFFD
00666 
00668 #define IMAGER_LINENO_ABORT 0xFFFC
00669 
00671 #define IMAGER_LINENO_SHORT 0xFFFB
00672 
00674 #define IMAGER_LINENO_XOR 0xFFFA
00675 
00676 
00680 typedef struct PACKED_ATTRIBUTE {
00681       uint32_t frame_number;        
00682       uint16_t line_number;         
00683       uint16_t horiz_resolution;    
00684       uint16_t vert_resolution;     
00685 } HeaderVideoLine;
00686 
00687 
00696 typedef struct PACKED_ATTRIBUTE {
00697     HeaderVideoLine header;
00698     uint8_t data[752];
00699 } PacketVideoLine;
00700 
00701 
00702 
00704 #define I2C_REGS_PER_FRAME 4
00705 
00713 typedef struct PACKED_ATTRIBUTE {
00714     HeaderVideoLine header;         
00715 
00716     uint32_t ticks_hi;              
00717     uint32_t ticks_lo;              
00718 
00719     uint32_t ticks_per_sec;         
00720 
00721     uint16_t i2c[I2C_REGS_PER_FRAME];   
00722     uint32_t i2c_valid;                 
00723 } PacketEOF;
00724 
00725 
00727 #define I2C_AUTO_REG_UNUSED ((uint32_t)-1)
00728 
00729 
00730 #endif //_IPCAM_PACKET_H_


wge100_camera
Author(s): Blaise Gassend, Patrick Mihelich, Eric MacIntosh, David Palchak
autogenerated on Sat Jun 8 2019 20:51:24