#include "build.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
Go to the source code of this file.
Classes | |
struct | NetHost |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
struct | PACKED_ATTRIBUTE |
Defines | |
#define | CAMERA_NAME_LEN 40 |
#define | FLASH_CALIBRATION_PAGENO (FLASH_MAX_PAGENO - 2) |
#define | FLASH_MAX_PAGENO 4095 |
#define | FLASH_NAME_PAGENO FLASH_MAX_PAGENO |
#define | FLASH_PAGE_SIZE 264 |
#define | I2C_AUTO_REG_UNUSED ((uint32_t)-1) |
Sentinel value that indicates no I2C read should be performed at that index. | |
#define | I2C_REGS_PER_FRAME 4 |
Number of I2C register to read during each video frame interval. | |
#define | IMAGER_LINENO_ABORT 0xFFFC |
Flags this video packet as being an Abort packet. | |
#define | IMAGER_LINENO_EOF 0xFFFF |
Flags this video packet as being an normal End Of Frame packet. | |
#define | IMAGER_LINENO_ERR 0xFFFE |
Flags this video packet as being a General Error packet. | |
#define | IMAGER_LINENO_OVF 0xFFFD |
Flags this video packet as being an Overflow packet. | |
#define | IMAGER_LINENO_SHORT 0xFFFB |
Flags a frame as Short (used only by the library). | |
#define | IMAGER_LINENO_XOR 0xFFFA |
(Not an error) provides an XOR line for the frame (used only by the library) | |
#define | IMAGER_MAGICLINE_MASK 0xFFF0 |
Line numbers that match this mask are reserved to indicate special packet types. | |
#define | PKT_ERROR_INVALID 2 |
Packet is not valid in this mode. | |
#define | PKT_ERROR_SYSERR 1 |
An internal system error occurred. | |
#define | PKT_ERROR_TIMEOUT 0 |
No valid response was received during the allotted interval. | |
#define | PKT_MAX_ID PKTT_RECONFIG_FPGA |
#define | PKT_STATUST_ERROR 1 |
Command could not be completed. See status_code for details. | |
#define | PKT_STATUST_OK 0 |
Command completed successfully. | |
#define | PKTT_ANNOUNCE 0x80 |
#define | PKTT_CONFIGURE 1 |
#define | PKTT_DISCOVER 0 |
#define | PKTT_FLASHDATA 0x83 |
#define | PKTT_FLASHREAD 6 |
#define | PKTT_FLASHWRITE 7 |
#define | PKTT_IMGRMODE 12 |
#define | PKTT_IMGRSETRES 13 |
#define | PKTT_RECONFIG_FPGA 15 |
#define | PKTT_RESET 4 |
#define | PKTT_SENSORDATA 0x84 |
#define | PKTT_SENSORRD 9 |
#define | PKTT_SENSORSEL 11 |
#define | PKTT_SENSORWR 10 |
#define | PKTT_STATUS 0x82 |
#define | PKTT_SYSCONFIG 14 |
#define | PKTT_TIMEREPLY 0x81 |
#define | PKTT_TIMEREQ 5 |
#define | PKTT_TRIGCTRL 8 |
#define | PKTT_VIDSTART 2 |
#define | PKTT_VIDSTOP 3 |
#define | WG_CAMCMD_PORT 1627 |
#define | WG_MAGIC_NO 0x00DEAF42UL |
Typedefs | |
typedef struct PACKED_ATTRIBUTE | HeaderVideoLine |
typedef struct PACKED_ATTRIBUTE | IdentityFlashPage |
typedef uint32_t | IPAddress |
typedef uint8_t | MACAddress [6] |
typedef struct PACKED_ATTRIBUTE | PacketAnnounce |
typedef struct PACKED_ATTRIBUTE | PacketConfigure |
typedef struct PACKED_ATTRIBUTE | PacketDiscover |
typedef struct PACKED_ATTRIBUTE | PacketEOF |
typedef struct PACKED_ATTRIBUTE | PacketFlashPayload |
typedef struct PACKED_ATTRIBUTE | PacketFlashRequest |
typedef struct PACKED_ATTRIBUTE | PacketGeneric |
typedef struct PACKED_ATTRIBUTE | PacketImagerMode |
typedef struct PACKED_ATTRIBUTE | PacketImagerSetRes |
typedef struct PACKED_ATTRIBUTE | PacketReconfigureFPGA |
typedef struct PACKED_ATTRIBUTE | PacketReset |
typedef struct PACKED_ATTRIBUTE | PacketSensorData |
typedef struct PACKED_ATTRIBUTE | PacketSensorRequest |
typedef struct PACKED_ATTRIBUTE | PacketSensorSelect |
typedef struct PACKED_ATTRIBUTE | PacketStatus |
typedef struct PACKED_ATTRIBUTE | PacketSysConfig |
typedef struct PACKED_ATTRIBUTE | PacketTimer |
typedef struct PACKED_ATTRIBUTE | PacketTimeRequest |
typedef struct PACKED_ATTRIBUTE | PacketTrigControl |
typedef struct PACKED_ATTRIBUTE | PacketVideoLine |
typedef struct PACKED_ATTRIBUTE | PacketVidStart |
typedef struct PACKED_ATTRIBUTE | PacketVidStop |
typedef uint16_t | UDPPort |
Contains definitions of all system command packet types.
Definition in file ipcam_packet.h.
#define CAMERA_NAME_LEN 40 |
Definition at line 64 of file ipcam_packet.h.
#define FLASH_CALIBRATION_PAGENO (FLASH_MAX_PAGENO - 2) |
Definition at line 63 of file ipcam_packet.h.
#define FLASH_MAX_PAGENO 4095 |
Definition at line 59 of file ipcam_packet.h.
#define FLASH_NAME_PAGENO FLASH_MAX_PAGENO |
Definition at line 62 of file ipcam_packet.h.
#define FLASH_PAGE_SIZE 264 |
Definition at line 60 of file ipcam_packet.h.
#define I2C_AUTO_REG_UNUSED ((uint32_t)-1) |
Sentinel value that indicates no I2C read should be performed at that index.
Definition at line 727 of file ipcam_packet.h.
#define I2C_REGS_PER_FRAME 4 |
Number of I2C register to read during each video frame interval.
Definition at line 704 of file ipcam_packet.h.
#define IMAGER_LINENO_ABORT 0xFFFC |
Flags this video packet as being an Abort packet.
Definition at line 668 of file ipcam_packet.h.
#define IMAGER_LINENO_EOF 0xFFFF |
Flags this video packet as being an normal End Of Frame packet.
Definition at line 659 of file ipcam_packet.h.
#define IMAGER_LINENO_ERR 0xFFFE |
Flags this video packet as being a General Error packet.
Definition at line 662 of file ipcam_packet.h.
#define IMAGER_LINENO_OVF 0xFFFD |
Flags this video packet as being an Overflow packet.
Definition at line 665 of file ipcam_packet.h.
#define IMAGER_LINENO_SHORT 0xFFFB |
Flags a frame as Short (used only by the library).
Definition at line 671 of file ipcam_packet.h.
#define IMAGER_LINENO_XOR 0xFFFA |
(Not an error) provides an XOR line for the frame (used only by the library)
Definition at line 674 of file ipcam_packet.h.
#define IMAGER_MAGICLINE_MASK 0xFFF0 |
Line numbers that match this mask are reserved to indicate special packet types.
Definition at line 656 of file ipcam_packet.h.
#define WG_CAMCMD_PORT 1627 |
All cameras will listen on this hard-coded port for commands
Definition at line 101 of file ipcam_packet.h.
#define WG_MAGIC_NO 0x00DEAF42UL |
All non-video packets will include this pre-defined magic number to identify them.
Definition at line 94 of file ipcam_packet.h.
typedef struct PACKED_ATTRIBUTE HeaderVideoLine |
This frame header is added to the beginning of every video line packet.
typedef struct PACKED_ATTRIBUTE IdentityFlashPage |
Structure of the last page of flash containing configuration information. The name is zero terminated. The 16-bit sum of the whole page should be 0xFFFF.
typedef uint32_t IPAddress |
Definition at line 74 of file ipcam_packet.h.
typedef uint8_t MACAddress[6] |
Definition at line 75 of file ipcam_packet.h.
typedef struct PACKED_ATTRIBUTE PacketAnnounce |
The PacketAnnounce is generated by the camera in response to a PacketDiscover or PacketConfigure. It provides complete information about the camera and the versions of its subcomponents.
typedef struct PACKED_ATTRIBUTE PacketConfigure |
A PacketConfigure is generated by the host to configure the session IP address of a specific camera. After a reset, all camera will boot with the same default IP address; to prevent address conflicts, all cameras must be Configured before any further actions are taken.
Valid States: The PacketConfigure is valid in the Unconfigured and Configured states. It may not be sent while the camera is streaming video.
Addressing: This packet should normally be directed to the broadcast address to ensure that the desired camera receives it regardless of the state of the host system's ARP cache. If the product_id and ser_no fields do not match those stored in the camera, then the camera will drop it.
Response: Once a camera has received a PacketConfigure and set its IP address, it will generate an PacketAnnounce from the new address so that the remote host can verify it was correctly set.
typedef struct PACKED_ATTRIBUTE PacketDiscover |
A PacketDiscover is sent from the host in order to detect cameras on the network segment and receive information about them. It can be directed to the broadcast address (MAC ff:ff:ff:ff:ff:ff) to detect all cameras or to the unicast address of one camera to detect only that specific camera.
The PacketDiscover is valid in all camera modes. It consists of a PacketGeneric with the type field set to PKTT_DISCOVER and an IP Address. When received, the camera will reply with a PacketAnnounce using the specified IP Address
typedef struct PACKED_ATTRIBUTE PacketEOF |
This packet is sent at the end of every normal video frame. It is also generated when an Imager failure (pipeline error or overflow) is detected.
Per Willow Garage request, the PacketEOF is a special case of the HeaderVideoLine, with the line number field set to 0xFFFF (IMAGER_LINENO_EOF).
typedef struct PACKED_ATTRIBUTE PacketFlashPayload |
A PacketFlashPayload may be generated by either the host or the camera. When generated by the camera, it is in response to a PacketFlashRequest and contains the flash data requested by that packet. In this case it will have type PKTT_FLASHDATA.
When generated by the host, it is sent to erase & write a page (264 bytes) worth of data into the Atmel dataflash. In this case it will have packet type PKTT_FLASHWRITE.
Valid States: A PKTT_FLASHWRITE is only valid in the Configured state due to the processing time required.
Addressing: A PKTT_FLASHWRITE packet may only be sent to the unicast address of a single camera.
Response: After the flash erase/write cycle has completed, the camera will respond to the originator of the PKTT_FLASHWRITE packet with a PacketStatus indicating success. The host should not send further packets until receiving the PacketStatus.
typedef struct PACKED_ATTRIBUTE PacketFlashRequest |
A PacketFlashRequest is sent by the host to request the contents of one Atmel dataflash page. Each page consists of 264 bytes and is requested by an address in the following format:
The address field Holds the 32 bit starting address:
If the start offset is non-zero, then the data will wrap back from the end of the page to the beginning. Normally, this is undesirable, so a start offset of zero should be used.
The AT45DB161D Atmel Dataflash used in this product has 4096 user-accessible flash pages of 264 bytes each.
Valid States: The PacketFlashRequest is only valid in the Configured state due to the processing time required.
Addressing: This packet may only be sent to the unicast address of a single camera.
Response: The camera will read the requested flash page and reply to the originator of the PacketFlashRequest with a PacketFlashPayload containing the data.
typedef struct PACKED_ATTRIBUTE PacketGeneric |
A PacketGeneric contains only the basic elements that are included in all camera command packets. In conjunction with GenericFrame it is used for pre-validating packets. Functions that generate packets with no data other than the 'type' field may also use a PacketGeneric.
typedef struct PACKED_ATTRIBUTE PacketImagerMode |
A PacketImagerMode packet is generated by the host to request a change in image sensor mode (resolution, framerate and binning) to one in a predefined list. In this product, there are 10 modes (0..9). The default mode after a reset is mode 2 (640x480x30fps). The specifics of these modes are defined elsewhere.
Valid States: The host may only generate a PacketImagerMode packet when the system is in the Configured state. Changing video mode while streaming is not allowed.
Addressing: A PacketSensorSelect packet may only be sent to the unicast address of a single camera.
Response: Once the camera has configured the requested mode, it will return a PacketStatus to the originating host to indicate success.
typedef struct PACKED_ATTRIBUTE PacketImagerSetRes |
The PacketImagerSetRes packet is used only when configuring non-standard image modes. It allows the host to manually configure the camera firmware for arbitrary image dimensions. The camera firmware must always be configured to match the dimensions of the frame coming out of the imager; if the camera is incorrectly configured, system failure could result.
In any case, the maximum value of the horizontal parameter is 752 bytes.
Valid States: The host may only send a PacketImagerSetRes packet when the camera is in the Configured state. Changing imager resolution while streaming is not allowed.
Addressing: A PacketImagerSetRes packet may only be sent to the unicast address of a single camera.
Response: Once the camera has configured the requested resolution, it will return a PacketStatus to the originating host to indicate success.
typedef struct PACKED_ATTRIBUTE PacketReconfigureFPGA |
A PacketReconfigureFPGA is generated by the host to immediately cause the camera to reconfigure the FPGA. All operations are terminated and all temporary state is reset. The PacketReconfigureCamera is a PacketGeneric with the type field set to PKTT_RECONFIG_FPGA.
Valid States: The PacketReset is valid in all operating modes
Addressing: This packet may be sent either to a unicast address of a single camera, or to all cameras on an Ethernet segment via the broadcast address.
Response: The camera reconfigures immediately about a second after receipt of this packet. There is no response generated, but the reconfiguration can be confirmed by subsequently sending a PacketDiscover.
typedef struct PACKED_ATTRIBUTE PacketReset |
A PacketReset is generated by the host to immediately return the camera to its power-up default state. All operations are terminated and all temporary state is reset. The PacketReset is a PacketGeneric with the type field set to PKTT_RESET.
Valid States: The PacketReset is valid in all operating modes
Addressing: This packet may be sent either to a unicast address of a single camera, or to all cameras on an Ethernet segment via the broadcast address.
Response: The camera resets immediately after receipt of this packet. There is no response generated, but the reset can be confirmed by subsequently sending a PacketDiscover.
typedef struct PACKED_ATTRIBUTE PacketSensorData |
A PacketSensorData may be generated by either the host or the camera. When generated by the camera it will have a type of PKTT_SENSORDATA and will contain the 16-bit data 'data' read from 8-bit image sensor I2C address 'address'.
When generated by the host, the type PKTT_SENSORWR will be assigned. A PKTT_SENSORWR packet is used to instruct the camera to write a 16-bit value ('data') into a location on the image sensor I2C bus specified by the 8-bit address 'address'.
Valid States: PacketTrigControl is valid in both Configured and Video states. However, the Host should pace its requests during Video mode to avoid exceeding the available processor time and network bandwidth.
Addressing: A PKTT_SENSORWR packet may only be sent to the unicast address of a single camera.
Response: Once the camera has written the requested value, it will return a PacketStatus to the originating host to indicate success.
typedef struct PACKED_ATTRIBUTE PacketSensorRequest |
A PacketSensorRequest is generated by the host to request the 16-bit value of a specific image sensor I2C register.
Valid States: PacketTrigControl is valid in both Configured and Video states. However, the Host should pace its requests during Video mode to avoid exceeding the available processor time and network bandwidth.
Addressing: A PacketSensorRequest packet may only be sent to the unicast address of a single camera.
Response: Once the camera has read the requested value, it will return a PacketSensorData packet to the host. This packet will contain the 16-bit data.
typedef struct PACKED_ATTRIBUTE PacketSensorSelect |
A PacketSensorSelect is generated by the host to specify the address of one of the I2C registers to be automatically read once per video frame. In this product, a maximum of four registers can be read.
This packet can also be used to disable reading of a particular index position by specifying an address of I2C_AUTO_REG_UNUSED ((uint32_t)-1).
Valid States: PacketSensorSelect is valid in both Configured and Video states. However, in Video mode the value of the automatically read register at 'index' is undefined between the time the PacketSensorSelect is sent and the end of the frame after the PacketStatus response is received.
Addressing: A PacketSensorSelect packet may only be sent to the unicast address of a single camera.
Response: Once the camera has configured the requested value, it will return a PacketStatus to the originating host to indicate success.
typedef struct PACKED_ATTRIBUTE PacketStatus |
A PacketStatus is generated by the camera in reply to a command from the host that does not require a detailed response. Normally it will indicate only success or failure. If failure, the type of failure is indicated by the status_code field.
typedef struct PACKED_ATTRIBUTE PacketSysConfig |
A PacketSysConfig is a one-time use packet generated by a host after a unit's initial programming. It specifies the permanent unique MAC address and serial number for a camera.
Valid States: The host may only send a PacketSysConfig packet when the camera is in the Configured state.
Addressing: A PacketImagerSetRes packet may only be sent to the unicast address of a single camera.
Response: Once the camera has programmed the MAC and serial, it will return a PacketStatus to the originating host to indicate success. Once the PacketStatus has been received, a PacketReset should be sent for the changes to take effect.
typedef struct PACKED_ATTRIBUTE PacketTimer |
A PacketTimer is generated by the camera in reply to a TimeRequest from the host. It contains the value of the 64-bit system time base, split between the ticks_hi and ticks_lo fields. The system time base is incremented once per clock cycle and is only reset after a hard reset of the camera board.
The system time base will roll over to zero after approximately 10,000 years of uptime.
An additional field 'ticks_per_sec' is supplied to convert time base clock ticks into seconds. To obtain microseconds from a PacketTimer, first combine ticks_hi and ticks_lo into a single 64-bit value, then divide by (ticks_per_sec/1000000). (Depending on host architecture, different numerical methods may be used to maintain precision)
typedef struct PACKED_ATTRIBUTE PacketTimeRequest |
A TimeRequest packet is generated by the host to request a reading of the camera's system time base. The TimeRequest packet is a PacketGeneric with the type field set to PKTT_TIMEREQ.
Valid States: The TimeRequest packet is valid in both the Configured and Video states. Higher latency will be present during the Video state due to increased processor and network load.
Addressing: This packet may only be sent to the unicast address of a single camera.
Response: The camera will read the system time base and respond to the originator of the TimeRequest with a PacketTimer.
typedef struct PACKED_ATTRIBUTE PacketTrigControl |
A PacketTrigControl will be generated by the host in order to set the type of trigger to use for a subsequent video stream. The change will not affect a stream in process; it is only activated at the reception of the next PacketVidStart.
Currently valid trigger types are Internal (0) and External (1).
Valid States: PacketTrigControl is valid in both Configured and Video states, but a change of trigger state will not take immediate effect when the camera is already in the Video state.
Addressing: A PKTT_FLASHWRITE packet may only be sent to the unicast address of a single camera.
Response: After the trigger type has been changed, the camera will respond to the originator of the PacketTrigControl with a Status packet indicating success.
typedef struct PACKED_ATTRIBUTE PacketVideoLine |
This packet is a normal line of video.
The data field is sized to accomodate the widest frame possible.
Per Willow Garage request, the PacketEOF is a special case of the PacketVideoLine, with the line number field set to IMAGER_LINENO_NOERR (per client request).
typedef struct PACKED_ATTRIBUTE PacketVidStart |
A PacketVidStart is generated by the host to instruct a camera to begin streaming video in the currently configured video mode. The 'receiver' field instructs the camera where to send the video.
Valid States: The PacketVidStart is only valid in the Configured state. Unconfigured cameras and cameras currently streaming will not respond to this packet.
Addressing: This packet may only be addressed to the unicast address of a single camera.
Response: Before starting the video stream, the camera will reply to the originator of the PacketVidStart with a Status packet indicating success.
typedef struct PACKED_ATTRIBUTE PacketVidStop |
A PacketVidStop is generated by the host to terminate video streaming from a camera. After the camera receives the PacketVidStop it will wait for the current frame to complete, then end transmission and revert to Configured mode. The PacketVidStop is a PacketGeneric with the type field set to PKTT_VIDSTOP.
Valid States: A PacketVidStop is only valid in the Video state.
Addressing: This packet may only be sent to the unicast address of a single camera.
Response: After the current frame has completed, the camera will reply to the originator of the PacketVidStop with a Status packet indicating success.
typedef uint16_t UDPPort |
Definition at line 76 of file ipcam_packet.h.