diff --git a/boostrap.sh b/boostrap.sh new file mode 100644 index 0000000..5ebf764 --- /dev/null +++ b/boostrap.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +git submodule update --init --recursive + +sh proto_gen.sh + +# create the program directories: +# ./build will be the executable is compiled +# ./data will contain the user files +mkdir build data +# run cmake +cd build +cmake ../src -DDETACH_KERNEL_DRIVER=ON + + diff --git a/proto_gen.sh b/proto_gen.sh new file mode 100644 index 0000000..c4d6d04 --- /dev/null +++ b/proto_gen.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +cd src/external/PiScan-protobuf + +protoc -I=. --cpp_out=. *.proto + +cd ../../.. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 707508e..aebd7dc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,7 +9,7 @@ set(CMAKE_BUILD_TYPE Debug) add_executable(piScan_backend piScan_backend.cpp) -include_directories(core drivers external scan server sigproc external/PiScan-protobuf/cpp) +include_directories(core drivers external scan server sigproc external/PiScan-protobuf) add_subdirectory(core) add_subdirectory(drivers) diff --git a/src/external/CMakeLists.txt b/src/external/CMakeLists.txt index 1d710d5..9b8885c 100644 --- a/src/external/CMakeLists.txt +++ b/src/external/CMakeLists.txt @@ -8,17 +8,17 @@ add_library(external convenience.c ) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/PiScan-protobuf/cpp) - target_include_directories(external PUBLIC PiScan-protobuf/cpp) - target_include_directories(piScan_backend PUBLIC PiScan-protobuf/cpp) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/PiScan-protobuf) + target_include_directories(external PUBLIC PiScan-protobuf) + target_include_directories(piScan_backend PUBLIC PiScan-protobuf) target_sources(external PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/PiScan-protobuf/cpp/context.pb.cc - ${CMAKE_CURRENT_SOURCE_DIR}/PiScan-protobuf/cpp/context.pb.h - ${CMAKE_CURRENT_SOURCE_DIR}/PiScan-protobuf/cpp/messages.pb.cc - ${CMAKE_CURRENT_SOURCE_DIR}/PiScan-protobuf/cpp/messages.pb.h - ${CMAKE_CURRENT_SOURCE_DIR}/PiScan-protobuf/cpp/request.pb.cc - ${CMAKE_CURRENT_SOURCE_DIR}/PiScan-protobuf/cpp/request.pb.h + ${CMAKE_CURRENT_SOURCE_DIR}/PiScan-protobuf/context.pb.cc + ${CMAKE_CURRENT_SOURCE_DIR}/PiScan-protobuf/context.pb.h + ${CMAKE_CURRENT_SOURCE_DIR}/PiScan-protobuf/messages.pb.cc + ${CMAKE_CURRENT_SOURCE_DIR}/PiScan-protobuf/messages.pb.h + ${CMAKE_CURRENT_SOURCE_DIR}/PiScan-protobuf/request.pb.cc + ${CMAKE_CURRENT_SOURCE_DIR}/PiScan-protobuf/request.pb.h ) diff --git a/src/external/PiScan-protobuf b/src/external/PiScan-protobuf index 16a4f2d..c65310f 160000 --- a/src/external/PiScan-protobuf +++ b/src/external/PiScan-protobuf @@ -1 +1 @@ -Subproject commit 16a4f2dfc4fb0eb969428c0c202b9b90464c807c +Subproject commit c65310f96340382fcbc2319a4820ff1258fec946 diff --git a/src/server/SocketServer.cpp b/src/server/SocketServer.cpp index be5379f..f9dc545 100644 --- a/src/server/SocketServer.cpp +++ b/src/server/SocketServer.cpp @@ -59,7 +59,7 @@ void SocketConnection::contextUpdate(ScannerContext context){ msg.set_allocated_scannercontext(ctx); msg.SerializeToArray(_writeBuffer, WRITE_BUFFER_LENGTH); - _startWrite(_writeBuffer, WRITE_BUFFER_LENGTH); + _startWrite(_writeBuffer, msg.ByteSize()); } void SocketConnection::contextUpdate(DemodContext context){ @@ -73,7 +73,7 @@ void SocketConnection::contextUpdate(DemodContext context){ msg.set_allocated_demodcontext(ctx); msg.SerializeToArray(_writeBuffer, WRITE_BUFFER_LENGTH); - _startWrite(_writeBuffer, WRITE_BUFFER_LENGTH); + _startWrite(_writeBuffer, msg.ByteSize()); } void SocketConnection::systemMessage(GeneralMessage message) { @@ -101,7 +101,7 @@ void SocketConnection::systemMessage(GeneralMessage message) { msg.set_allocated_generalmessage(ctx); msg.SerializeToArray(_writeBuffer, WRITE_BUFFER_LENGTH); - _startWrite(_writeBuffer, WRITE_BUFFER_LENGTH); + _startWrite(_writeBuffer, msg.ByteSize()); } void SocketConnection::_startRead() { @@ -125,19 +125,14 @@ void SocketConnection::_handleRead(const boost::system::error_code& err, piscan_pb::ClientToServer msg; msg.ParseFromArray(_readBuffer, bytes_transferred); - std::cerr << msg.DebugString(); - switch(msg.type()){ case piscan_pb::ClientToServer_Type_GENERAL_REQUEST: - std::cerr << "general" << std::endl; _handleGeneralRequest(msg.generalrequest()); break; case piscan_pb::ClientToServer_Type_SCANNER_STATE_REQUEST: - std::cerr << "scanner" << std::endl; _handleScanStateRequest(msg.scanstaterequest()); break; case piscan_pb::ClientToServer_Type_DEMOD_REQUEST: - std::cerr << "demod" << std::endl; _handleDemodRequest(msg.demodrequest()); break; default: