diff --git a/Doxyfile b/Doxyfile index 18ad2063680aac2dc9f8515f3b8e7813fdc5895f..3c798c937a8dbdd4fc1bd9b77a78c4868cf3ba3d 100644 --- a/Doxyfile +++ b/Doxyfile @@ -54,7 +54,8 @@ FILE_PATTERNS = *.h \ *.hh \ *.H \ *.cpp \ - *.cxx + *.cxx \ + *.c RECURSIVE = YES EXCLUDE = PacketLibDemo.h EXCLUDE_SYMLINKS = NO diff --git a/Makefile b/Makefile index 4e053c2aff40ba0b3c36bc1d9eff3b98142b00cd..b2a788225b10034f5f7d8e840903781088e47f75 100644 --- a/Makefile +++ b/Makefile @@ -105,12 +105,13 @@ vpath %.o $(OBJECTS_DIR) INCLUDE=$(foreach dir,$(INCLUDE_DIR), $(wildcard $(dir)/*.h)) SOURCE=$(foreach dir,$(SOURCE_DIR), $(wildcard $(dir)/*.cpp)) +SOURCEDOX=$(SOURCE) SOURCE+=$(foreach dir,$(SOURCE_DIR), $(wildcard $(dir)/*.c)) #Objects to build OBJECTS=$(addsuffix .o, $(basename $(notdir $(SOURCE)))) #only for documentation generation DOC_INCLUDE= $(addprefix $(DOXY_SOURCE_DIR)/, $(notdir $(INCLUDE))) -DOC_SOURCE= $(addprefix $(DOXY_SOURCE_DIR)/, $(notdir $(SOURCE))) +DOC_SOURCE= $(addprefix $(DOXY_SOURCE_DIR)/, $(notdir $(SOURCEDOX))) ####### 7) Only for library generation @@ -143,6 +144,10 @@ $(DOXY_SOURCE_DIR)/%.h : %.h $(DOXY_SOURCE_DIR)/%.cpp : %.cpp cp $< $@ + +$(DOXY_SOURCE_DIR)/%.c : %.c + cp $< $@ + ####### 10) Build rules diff --git a/PacketLib.xcodeproj/project.pbxproj b/PacketLib.xcodeproj/project.pbxproj index 945afe972ad513a829fd2e775df1faed30a3c298..fc591a4c1f7b12d11d42174bcc0a5ca4f2857734 100644 --- a/PacketLib.xcodeproj/project.pbxproj +++ b/PacketLib.xcodeproj/project.pbxproj @@ -120,6 +120,36 @@ DD7468B218CF00D10028146F /* PacketBufferV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PacketBufferV.h; sourceTree = "<group>"; }; DD7468B318CF00E30028146F /* PacketBufferQ.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PacketBufferQ.cpp; sourceTree = "<group>"; }; DD7468B418CF00E30028146F /* PacketBufferV.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PacketBufferV.cpp; sourceTree = "<group>"; }; + DD8A41F41A95C11600565702 /* ChangeLog */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ChangeLog; sourceTree = "<group>"; }; + DD8A41F71A95C11600565702 /* 39_01.packet */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = 39_01.packet; sourceTree = "<group>"; }; + DD8A41F81A95C11700565702 /* BURST.packet */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = BURST.packet; sourceTree = "<group>"; }; + DD8A41F91A95C11700565702 /* BURST.stream */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = BURST.stream; sourceTree = "<group>"; }; + DD8A41FA1A95C11700565702 /* GRID.01.packet */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = GRID.01.packet; sourceTree = "<group>"; }; + DD8A41FB1A95C11700565702 /* GRID.stream */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = GRID.stream; sourceTree = "<group>"; }; + DD8A41FC1A95C11700565702 /* headerESATC.header */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = headerESATC.header; sourceTree = "<group>"; }; + DD8A41FD1A95C11700565702 /* headerESATM.header */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = headerESATM.header; sourceTree = "<group>"; }; + DD8A41FE1A95C11700565702 /* p3901.stream */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = p3901.stream; sourceTree = "<group>"; }; + DD8A41FF1A95C11700565702 /* rblock_type_0_1.rblock */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rblock_type_0_1.rblock; sourceTree = "<group>"; }; + DD8A42001A95C11700565702 /* rblock_type_2.rblock */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rblock_type_2.rblock; sourceTree = "<group>"; }; + DD8A42011A95C11700565702 /* rblock_type_3.rblock */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rblock_type_3.rblock; sourceTree = "<group>"; }; + DD8A42021A95C11700565702 /* rblock_type_E.rblock */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rblock_type_E.rblock; sourceTree = "<group>"; }; + DD8A42031A95C11700565702 /* TC_start.packet */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TC_start.packet; sourceTree = "<group>"; }; + DD8A42041A95C11700565702 /* TC_stop.packet */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TC_stop.packet; sourceTree = "<group>"; }; + DD8A42051A95C11700565702 /* in.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = in.cpp; sourceTree = "<group>"; }; + DD8A42061A95C11700565702 /* msgqclient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = msgqclient.cpp; sourceTree = "<group>"; }; + DD8A42071A95C11700565702 /* msgqserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = msgqserver.cpp; sourceTree = "<group>"; }; + DD8A42081A95C11700565702 /* out.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = out.cpp; sourceTree = "<group>"; }; + DD8A420A1A95C11700565702 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; + DD8A420B1A95C11700565702 /* msgqclient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = msgqclient.cpp; sourceTree = "<group>"; }; + DD8A420C1A95C11700565702 /* msgqserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = msgqserver.cpp; sourceTree = "<group>"; }; + DD8A420D1A95C11700565702 /* socketin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = socketin.cpp; sourceTree = "<group>"; }; + DD8A420E1A95C11700565702 /* socketout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = socketout.cpp; sourceTree = "<group>"; }; + DD8A420F1A95C11700565702 /* TestSHMClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestSHMClient.cpp; sourceTree = "<group>"; }; + DD8A42101A95C11700565702 /* TestSHMServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestSHMServer.cpp; sourceTree = "<group>"; }; + DD8A42111A95C11700565702 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; }; + DD8A42121A95C11700565702 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; }; + DD8A42131A95C11700565702 /* TODO */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TODO; sourceTree = "<group>"; }; + DD8A42151A95C11700565702 /* packetlib_example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = packetlib_example.cpp; sourceTree = "<group>"; }; DDB3B86B18CA2F8700918955 /* ByteStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteStream.h; sourceTree = "<group>"; }; DDB3B86C18CA2F8700918955 /* ConfigurationFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConfigurationFile.h; sourceTree = "<group>"; }; DDB3B86D18CA2F8700918955 /* DataFieldHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataFieldHeader.h; sourceTree = "<group>"; }; @@ -223,9 +253,79 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + DD8A41F31A95C11600565702 /* examples */ = { + isa = PBXGroup; + children = ( + DD8A41F41A95C11600565702 /* ChangeLog */, + DD8A41F51A95C11600565702 /* examples */, + DD8A42091A95C11700565702 /* examples2 */, + DD8A42111A95C11700565702 /* Makefile */, + DD8A42121A95C11700565702 /* README */, + DD8A42131A95C11700565702 /* TODO */, + DD8A42141A95C11700565702 /* xml */, + ); + path = examples; + sourceTree = "<group>"; + }; + DD8A41F51A95C11600565702 /* examples */ = { + isa = PBXGroup; + children = ( + DD8A41F61A95C11600565702 /* config_files */, + DD8A42051A95C11700565702 /* in.cpp */, + DD8A42061A95C11700565702 /* msgqclient.cpp */, + DD8A42071A95C11700565702 /* msgqserver.cpp */, + DD8A42081A95C11700565702 /* out.cpp */, + ); + path = examples; + sourceTree = "<group>"; + }; + DD8A41F61A95C11600565702 /* config_files */ = { + isa = PBXGroup; + children = ( + DD8A41F71A95C11600565702 /* 39_01.packet */, + DD8A41F81A95C11700565702 /* BURST.packet */, + DD8A41F91A95C11700565702 /* BURST.stream */, + DD8A41FA1A95C11700565702 /* GRID.01.packet */, + DD8A41FB1A95C11700565702 /* GRID.stream */, + DD8A41FC1A95C11700565702 /* headerESATC.header */, + DD8A41FD1A95C11700565702 /* headerESATM.header */, + DD8A41FE1A95C11700565702 /* p3901.stream */, + DD8A41FF1A95C11700565702 /* rblock_type_0_1.rblock */, + DD8A42001A95C11700565702 /* rblock_type_2.rblock */, + DD8A42011A95C11700565702 /* rblock_type_3.rblock */, + DD8A42021A95C11700565702 /* rblock_type_E.rblock */, + DD8A42031A95C11700565702 /* TC_start.packet */, + DD8A42041A95C11700565702 /* TC_stop.packet */, + ); + path = config_files; + sourceTree = "<group>"; + }; + DD8A42091A95C11700565702 /* examples2 */ = { + isa = PBXGroup; + children = ( + DD8A420A1A95C11700565702 /* main.cpp */, + DD8A420B1A95C11700565702 /* msgqclient.cpp */, + DD8A420C1A95C11700565702 /* msgqserver.cpp */, + DD8A420D1A95C11700565702 /* socketin.cpp */, + DD8A420E1A95C11700565702 /* socketout.cpp */, + DD8A420F1A95C11700565702 /* TestSHMClient.cpp */, + DD8A42101A95C11700565702 /* TestSHMServer.cpp */, + ); + path = examples2; + sourceTree = "<group>"; + }; + DD8A42141A95C11700565702 /* xml */ = { + isa = PBXGroup; + children = ( + DD8A42151A95C11700565702 /* packetlib_example.cpp */, + ); + path = xml; + sourceTree = "<group>"; + }; DDB3B85F18CA2F5C00918955 = { isa = PBXGroup; children = ( + DD8A41F31A95C11600565702 /* examples */, DD3AB43119459AFB00498F60 /* Makefile */, DD6C793619255A6A00406949 /* README */, DD6C793519255A5E00406949 /* Doxyfile */, diff --git a/PacketLib.xcodeproj/project.xcworkspace/xcshareddata/PacketLib.xccheckout b/PacketLib.xcodeproj/project.xcworkspace/xcshareddata/PacketLib.xccheckout index b8411a5f681b015dbf026a2202e1fb0ee0e984a1..b64f3fcca61f7ae82475913e1ce80a0c9cedb853 100644 --- a/PacketLib.xcodeproj/project.xcworkspace/xcshareddata/PacketLib.xccheckout +++ b/PacketLib.xcodeproj/project.xcworkspace/xcshareddata/PacketLib.xccheckout @@ -11,17 +11,17 @@ <key>IDESourceControlProjectOriginsDictionary</key> <dict> <key>87AE3A47C426A969B4ECB716011DCD84ED0D145E</key> - <string>ssh://github.com/ASTRO-BO/PacketLib.git</string> + <string>github.com:ASTRO-BO/PacketLib.git</string> </dict> <key>IDESourceControlProjectPath</key> - <string>PacketLib.xcodeproj/project.xcworkspace</string> + <string>PacketLib.xcodeproj</string> <key>IDESourceControlProjectRelativeInstallPathDictionary</key> <dict> <key>87AE3A47C426A969B4ECB716011DCD84ED0D145E</key> <string>../..</string> </dict> <key>IDESourceControlProjectURL</key> - <string>ssh://github.com/ASTRO-BO/PacketLib.git</string> + <string>github.com:ASTRO-BO/PacketLib.git</string> <key>IDESourceControlProjectVersion</key> <integer>111</integer> <key>IDESourceControlProjectWCCIdentifier</key> diff --git a/PacketLib.xcodeproj/project.xcworkspace/xcuserdata/bulgarelli.xcuserdatad/UserInterfaceState.xcuserstate b/PacketLib.xcodeproj/project.xcworkspace/xcuserdata/bulgarelli.xcuserdatad/UserInterfaceState.xcuserstate index d4174adce4e25c71b22efee480605abc622c5d2b..4e0cc302b41156a28f35e8ab4d5952c4598afad2 100644 Binary files a/PacketLib.xcodeproj/project.xcworkspace/xcuserdata/bulgarelli.xcuserdatad/UserInterfaceState.xcuserstate and b/PacketLib.xcodeproj/project.xcworkspace/xcuserdata/bulgarelli.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/examples/xml/packetlib_example.cpp b/examples/xml/packetlib_example.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4859bbe2edb69b0950a4df7c91ef312f8b5b4467 --- /dev/null +++ b/examples/xml/packetlib_example.cpp @@ -0,0 +1,93 @@ +/**************************************************************************e + PacketLib example using RTA Prototype2 raw format + --------------------------------------------------------------------------- + copyright : (C) 2015 Andrea Zoli + email : zoli@iasfbo.inaf.it + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software for non commercial purpose * + * and for public research institutes; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License. * + * For commercial purpose see appropriate license terms * + * * + ***************************************************************************/ +#include <iostream> +#include <packet/PacketStream.h> +#include <packet/PacketBufferV.h> +#include <packet/Field.h> +#include <cstdlib> +#include <cassert> + + + +int main(int argc, char* argv[]) +{ + if(argc <= 2) { + std::cout << "Wrong arguments, please provide config file and raw input file." << std::endl; + std::cout << argv[0] << " config.xml input.raw" << std::endl; + return 1; + } + + // getting the xml description information through the Packet. + PacketLib::PacketStream ps(argv[1]); + PacketLib::Packet* packetType; + try { + packetType = ps.getPacketType("triggered_telescope1_30GEN"); + + PacketLib::Field* apid = packetType->getPacketHeader()->getField("APID"); + std::cout << apid->getType() << std::endl; + assert(apid->getType() == PacketLib::LogicalFieldDataType::UINT11); + assert(apid->getName().compare("APID") == 0); + + PacketLib::Field* arrayID = packetType->getPacketDataFieldHeader()->getField("ArrayID"); + assert(arrayID->getType() == PacketLib::LogicalFieldDataType::UINT16); + assert(arrayID->getName().compare("ArrayID") == 0); + } + catch(PacketLib::PacketException* e) { + std::cerr << "Bad config file: " << e->geterror() << std::endl; + exit(EXIT_FAILURE); + } + + // load the event list from .raw file + PacketLib::PacketBufferV rawPackets(argv[1], argv[2]); + rawPackets.load(); + + for(unsigned int i=0; i<10; i++) { + PacketLib::ByteStreamPtr rawPacket = rawPackets.getNext(); + PacketLib::Packet* packet = ps.getPacket(rawPacket); + + // use reflection interface to read content + uint16_t apid = packet->getPacketHeader()->getFieldValue("APID"); + uint16_t arrayID = packet->getPacketDataFieldHeader()->getFieldValue("ArrayID"); + uint16_t npixels = packet->getPacketSourceDataField()->getFieldValue("Number of pixels"); + uint16_t nsamples = packet->getPacketSourceDataField()->getFieldValue("Number of samples"); + + std::cout << apid << " " << arrayID << " " << npixels << " " << nsamples << std::endl; + + + //get each single pixel as a 1-dimensional array + //for(unsigned int j=0; j<npixels; j++) { + // PacketLib::byte* buff = packet->getPacketSourceDataField()->getBlock(j)->getByteStream()->getStream(); + //} + + for(uint16_t pixel=0; pixel<npixels; pixel++) { + for(uint16_t sample=0; sample<nsamples; sample++) { + cout << packet->getPacketSourceDataField()->getBlock(pixel)->getFieldValue(sample) << " "; + } + cout << endl; + } + + // use reflection interface to write content + // similar the above using setFieldValue_16ui(); + + /// get all the waveforms of a camera as 2-dimensional array + PacketLib::byte* buff = packet->getData()->getStream(); + PacketLib::dword buffSize = packet->getData()->size(); + + + } + + return EXIT_SUCCESS; +}