diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 1cc394d..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,78 +0,0 @@ -cmake_minimum_required(VERSION 3.0.0) -project(scanservice) -add_compile_options(-std=c++14) -#set (CMAKE_GENERATOR "/home/holdtecs/zzm-linux/rk3288-linux/prebuilts/gcc/linux-x86/arm/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++") - - - - -#交叉编译配置 -# set(CMAKE_SYSTEM_NAME Linux) -# set(CMAKE_SYSTEM_PROCESSOR arm) - -#可选,配置roofs和安装路径如果存在 -#set(linux_sdk_path /home/holdtecs/zzm-linux/rk3288-linux) -#set(linux_sdk_path /mnt/disk2/linux-rhx/rk3288-linux) -#set(CMAKE_SYSROOT ${linux_sdk_path}/buildroot/output/rockchip_rk3288/host/arm-buildroot-linux-gnueabihf/sysroot) -# set(CMAKE_STAGING_PREFIX ${PROJECT_SOURCE_DIR}/install) - -#编译工具配置 -#set(tools ${linux_sdk_path}/prebuilts/gcc/linux-x86/arm/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf) -# set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) -# set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) -# set(CMAKE_LIBRARY_ARCHITECTURE arm) -add_subdirectory(fpga) -set(-mfloat-abi=hard) - -# set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -# set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -# set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -# set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) -# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -fvectorize") -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -fvectorize") - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") - -set(OpenCV_DIR /home/modehua/sdk/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/usr/include/opencv4/) -#set(OpenCV_DIR /home/holdtecs/zzm-linux/fs/usr/lib) -#find_package( OpenCV 3 REQUIRED ) -include_directories( ${OpenCV_INCLUDE_DIRS} ) - -FILE(GLOB SRC "*.cpp" "*.h" "*.c") -FILE(GLOB IMAGEPRO "imageprocess/*.h" "imageprocess/*.cpp" ) -FILE(GLOB FPGA "fpga/*.h" "fpga/*.cpp" ) -# message(STATUS "SRC:" ${SRC}) -# message(STATUS "IMAGEPRO:" ${IMAGEPRO}) - #message(STATUS "FPGA:" ${FPGA}) - set(CMAKE_BUILD_TYPE "Release") - - include_directories( - fpga - imageprocess - imageprocess/include - #/home/modehua/sdk/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/usr/include/opencv4/ - ) - - -add_executable(${PROJECT_NAME} ${SRC}) - -#优化代码大小 - SET(-CMAKE_BUILD_TYPE "Release") -install(TARGETS ${PROJECT_NAME} DESTINATION bin) - - -add_custom_command(TARGET ${PROJECT_NAME} - POST_BUILD - COMMAND $ENV{STRIP} -s ${PROJECT_NAME}) - - -set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "-s") -target_link_libraries(${PROJECT_NAME} ${PROJECT_BINARY_DIR}/bin/libfpgaupdate.a) -target_link_libraries(${PROJECT_NAME} opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs turbojpeg pthread ) -target_link_libraries(${PROJECT_NAME} pthread ) - -target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR}/fpga - /home/modehua/sdk/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/usr/include/opencv4/ -) \ No newline at end of file diff --git a/JsonConfig.cpp b/JsonConfig.cpp deleted file mode 100644 index b43c775..0000000 --- a/JsonConfig.cpp +++ /dev/null @@ -1,282 +0,0 @@ -#include "JsonConfig.h" -#include -#include -#include -#include -#define SCAN_INFO_TITLE "ScanInfo" -#define SCAN_TOTAL "TotalScanned" -#define SCAN_ROLLERNUM "RollerNum" -#define SCAN_CUONUM "CuoNum" -#define SCAN_JAMINNUM "JamInNum" -#define SCAN_JAMOUTNUM "JamOutNum" -#define SCAN_DOUNUM "DoubleNum" -#define SCAN_ERRORNUM "ErrorNum" -#define SCAN_SERIALNUM "SerialNum" -#define SCAN_FWVERSION "FWVersion" -#define SCAN_HRATIO "HRatio" -#define SCAN_VRATIO "VRatio" -#define SCAN_SLEEPTIME "SleepTime" -#define SCAN_TOKEN "ScannerToken" -#define SCAN_SPEEDMODE "SpeedMode" -#define SCAN_VID "VID" -#define SCAN_PID "PID" - -#define TOKEN_DEFAULT " " -JsonConfig::JsonConfig() -{ - if (access(SCANNER_SCAN_INFO_PATH, F_OK) == -1) //不存在 - { - ScannerScanInfo defaultinfo = CreateDefaultScanInfo(); - SaveScanInfo(defaultinfo); - } -} -JsonConfig::JsonConfig(ConfigType type) : m_cfgType(type) -{ -} - -JsonConfig::~JsonConfig() -{ -} - -// bool JsonConfig::ReadParam(FPGAConfigParam ¶m) -// { -// bool ret = false; -// if (access(cfgPaths[m_cfgType].c_str(), F_OK) == -1) -// { -// return ret; -// } -// std::ifstream i(cfgPaths[m_cfgType]); -// json j; -// i >> j; -// auto &jobject = j[cfgPrefix[m_cfgType]]; -// jobject[cfgPrefix[m_cfgType] + "ExposureF"].get_to(param.ExposureF); -// jobject[cfgPrefix[m_cfgType] + "ExposureB"].get_to(param.ExposureB); -// jobject[cfgPrefix[m_cfgType] + "GainF"].get_to(param.GainF); -// jobject[cfgPrefix[m_cfgType] + "GainB"].get_to(param.GainB); -// jobject[cfgPrefix[m_cfgType] + "OffsetF"].get_to(param.OffsetF); -// jobject[cfgPrefix[m_cfgType] + "OffsetB"].get_to(param.OffsetB); -// return ret; -// } - -// void JsonConfig::WriteParam(FPGAConfigParam &t_param) -// { -// FPGAConfigParam param; -// if (access(cfgPaths[m_cfgType].c_str(), F_OK) == -1) -// { -// LOG("Not found config %s \n", cfgPaths[m_cfgType].c_str()); -// param = CreateDefault(); -// } -// else -// param = t_param; - -// LOG("start save %s \n", cfgPaths[m_cfgType].c_str()); -// json m_json; -// auto &jobject = m_json[cfgPrefix[m_cfgType]]; -// jobject[cfgPrefix[m_cfgType] + "ExposureF"] = {param.ExposureF[0], param.ExposureF[1], param.ExposureF[2]}; -// jobject[cfgPrefix[m_cfgType] + "ExposureB"] = {param.ExposureB[0], param.ExposureB[1], param.ExposureB[2]}; -// jobject[cfgPrefix[m_cfgType] + "GainF"] = {param.GainF[0], param.GainF[1], param.GainF[2], param.GainF[3], param.GainF[4], param.GainF[5]}; -// jobject[cfgPrefix[m_cfgType] + "GainB"] = {param.GainB[0], param.GainB[1], param.GainB[2], param.GainB[3], param.GainB[4], param.GainB[5]}; -// jobject[cfgPrefix[m_cfgType] + "OffsetF"] = {param.OffsetF[0], param.OffsetF[1], param.OffsetF[2], param.OffsetF[3], param.OffsetF[4], param.OffsetF[5]}; -// jobject[cfgPrefix[m_cfgType] + "OffsetB"] = {param.OffsetB[0], param.OffsetB[1], param.OffsetB[2], param.OffsetB[3], param.OffsetB[4], param.OffsetB[5]}; -// std::ofstream o(cfgPaths[m_cfgType]); -// o << std::setw(4) << m_json << std::endl; -// LOG("save config %s down \n", cfgPaths[m_cfgType].c_str()); -// } - -// FPGAConfigParam JsonConfig::CreateDefault() -// { -// std::string savePath = cfgPaths[m_cfgType]; -// FPGAConfigParam param = {0}; -// for (size_t i = 0; i < 3; i++) -// { -// param.ExposureF[i] = 259; -// param.ExposureB[i] = 238; -// } - -// for (size_t i = 0; i < 6; i++) -// { -// param.GainB[i] = 30; -// param.GainF[i] = 30; -// param.OffsetB[i] = param.OffsetF[i] = 119; -// } -// return param; -// } - -ScannerScanInfo JsonConfig::CreateDefaultScanInfo() -{ - ScannerScanInfo info; - info.CuoNum = 0; - info.DoubleNum = 0; - info.ErrorNum = 0; - info.JamInNum = 0; - info.JamOutNum = 0; - info.FWVersion = FWVERSION; - info.SerialNum = SERIALNUM; - info.TotalScanned = 0; - info.RollerNum = 0; - info.HRatio = 1065353216;//(=(float)1.0) - info.VRatio = 1065353216; - info.SleepTime=3600; - info.Token=TOKEN_DEFAULT; - info.SpeedMode = 4; - l_it = mapFradme_SP.find(info.SpeedMode); - info.FWVersion = l_it->second.FWVERSIO; - - info.VID = 0x3072; - info.PID = 0x0300; - - return info; -} - -ScannerScanInfo JsonConfig::GetScanInfo() -{ - ScannerScanInfo info; - if (access(SCANNER_SCAN_INFO_PATH, F_OK) != 0) - { - printf("/mnt/flash-disk/huago/jsonconfig.json do not exist!\n"); - info = CreateDefaultScanInfo(); - SaveScanInfo(info); - return info; - } - std::ifstream i(SCANNER_SCAN_INFO_PATH); - auto pos = i.tellg(); - i.seekg(0, ios::end); - if(i.tellg()<=2) - { - printf("/mnt/flash-disk/huago/jsonconfig.json file size < 2!\n"); - info = CreateDefaultScanInfo(); - SaveScanInfo(info); - return info; - } - json j; - i.seekg(pos); - { - std::lock_guard m_c(m_lock); - i >> j; - i.close(); - } - - auto &jobject = j[SCAN_INFO_TITLE]; - - if (jobject.contains(SCAN_TOTAL)) - jobject[SCAN_TOTAL].get_to(info.TotalScanned); - else - info.TotalScanned = 0; - - if (jobject.contains(SCAN_ROLLERNUM)) - jobject[SCAN_ROLLERNUM].get_to(info.RollerNum); - else - info.RollerNum = 0; - - if (jobject.contains(SCAN_CUONUM)) - jobject[SCAN_CUONUM].get_to(info.CuoNum); - else - info.CuoNum = 0; - - if (jobject.contains(SCAN_JAMINNUM)) - jobject[SCAN_JAMINNUM].get_to(info.JamInNum); - else - info.JamInNum = 0; - - if (jobject.contains(SCAN_JAMOUTNUM)) - jobject[SCAN_JAMOUTNUM].get_to(info.JamOutNum); - else - info.JamOutNum = 0; - - if (jobject.contains(SCAN_DOUNUM)) - jobject[SCAN_DOUNUM].get_to(info.DoubleNum); - else - info.DoubleNum = 0; - - if (jobject.contains(SCAN_ERRORNUM)) - jobject[SCAN_ERRORNUM].get_to(info.ErrorNum); - else - info.ErrorNum = 0; - - if (jobject.contains(SCAN_SERIALNUM)) - jobject[SCAN_SERIALNUM].get_to(info.SerialNum); - else - info.SerialNum = SERIALNUM; - - if (jobject.contains(SCAN_FWVERSION)) - jobject[SCAN_FWVERSION].get_to(info.FWVersion); - else - info.FWVersion = l_it->second.FWVERSIO; - - if (jobject.contains(SCAN_HRATIO)) - jobject[SCAN_HRATIO].get_to(info.HRatio); - else - info.HRatio = 1065353216;//默认 1.0f - - if (jobject.contains(SCAN_VRATIO)) - jobject[SCAN_VRATIO].get_to(info.VRatio); - else - info.VRatio = 1065353216;//默认 1.0f - - if (jobject.contains(SCAN_SLEEPTIME)) - jobject[SCAN_SLEEPTIME].get_to(info.SleepTime); - else - info.SleepTime = 3600;//默认 1.0f - - if(jobject.contains(SCAN_TOKEN)) - jobject[SCAN_TOKEN].get_to(info.Token); - else - { - info.Token=TOKEN_DEFAULT; - } - - if(jobject.contains(SCAN_SPEEDMODE)) - jobject[SCAN_SPEEDMODE].get_to(info.SpeedMode); - else - { - info.SpeedMode = 4; - } - - if(jobject.contains(SCAN_VID)) - jobject[SCAN_VID].get_to(info.VID); - else - { - info.VID = 0x3072; - } - - - if(jobject.contains(SCAN_PID)) - jobject[SCAN_PID].get_to(info.PID); - else - { - #ifdef G400 - info.PID = 0x0400; - #else - info.PID = 0x0300; - #endif - } - return info; -} - -void JsonConfig::SaveScanInfo(const ScannerScanInfo &info) -{ - json m_json; - auto &jobject = m_json[SCAN_INFO_TITLE]; - jobject[SCAN_TOTAL] = info.TotalScanned; - jobject[SCAN_ROLLERNUM] = info.RollerNum; - jobject[SCAN_CUONUM] = info.CuoNum; - jobject[SCAN_JAMINNUM] = info.JamInNum; - jobject[SCAN_JAMOUTNUM] = info.JamOutNum; - jobject[SCAN_DOUNUM] = info.DoubleNum; - jobject[SCAN_ERRORNUM] = info.ErrorNum; - jobject[SCAN_SERIALNUM] = info.SerialNum; - jobject[SCAN_FWVERSION] = info.FWVersion; - jobject[SCAN_HRATIO]= info.HRatio; - jobject[SCAN_VRATIO] = info.VRatio; - jobject[SCAN_SLEEPTIME] = info.SleepTime; - jobject[SCAN_TOKEN] = info.Token; - jobject[SCAN_SPEEDMODE] = info.SpeedMode; - jobject[SCAN_VID] = info.VID; - jobject[SCAN_PID] = info.PID; - std::lock_guard m_c(m_lock); - std::ofstream o(SCANNER_SCAN_INFO_PATH); - //std::cout< +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + int fd; + int ret; + + ret = mkfifo("my_fifo", 0666); + if(ret != 0) + { + perror("mkfifo"); + } + + printf("before open\n"); + fd = open("my_fifo", O_WRONLY); //等着只读 + if(fd < 0) + { + perror("open fifo"); + } + + printf("after open\n"); + + + sleep(5); + char send[100] = "100"; + write(fd, send, strlen(send)); + printf("write to my_fifo buf=%s\n", send); + while (1) + { + /* code */ + } + + + + return 0; +} \ No newline at end of file diff --git a/sleep_processes_code/CMakeLists.txt b/sleep_processes_code/CMakeLists.txt new file mode 100644 index 0000000..03d32ec --- /dev/null +++ b/sleep_processes_code/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.0.0) +project(sleep_processes) +add_compile_options(-std=c++14) +#set (CMAKE_GENERATOR "/home/holdtecs/zzm-linux/rk3288-linux/prebuilts/gcc/linux-x86/arm/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++") + + + + + + + + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") + + + +FILE(GLOB SRC "*.cpp" "*.h" "*.c") +FILE(GLOB IMAGEPRO "imageprocess/*.h" "imageprocess/*.cpp" ) +FILE(GLOB FPGA "fpga/*.h" "fpga/*.cpp" ) + + set(CMAKE_BUILD_TYPE "Release") + + + +add_executable(${PROJECT_NAME} ${SRC}) + +#优化代码大小 + SET(-CMAKE_BUILD_TYPE "Release") +install(TARGETS ${PROJECT_NAME} DESTINATION bin) + + +add_custom_command(TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND $ENV{STRIP} -s ${PROJECT_NAME}) + + +set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "-s") + +target_link_libraries(${PROJECT_NAME} opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs turbojpeg pthread ) +target_link_libraries(${PROJECT_NAME} pthread ) + diff --git a/sleep_processes_code/JsonConfig.cpp b/sleep_processes_code/JsonConfig.cpp new file mode 100644 index 0000000..9de7589 --- /dev/null +++ b/sleep_processes_code/JsonConfig.cpp @@ -0,0 +1,161 @@ +#include "JsonConfig.h" +#include +#include +#include +#include +#define SCAN_INFO_TITLE "ScanInfo" +#define SCAN_TOTAL "TotalScanned" +#define SCAN_ROLLERNUM "RollerNum" +#define SCAN_CUONUM "CuoNum" +#define SCAN_JAMINNUM "JamInNum" +#define SCAN_JAMOUTNUM "JamOutNum" +#define SCAN_DOUNUM "DoubleNum" +#define SCAN_ERRORNUM "ErrorNum" +#define SCAN_SERIALNUM "SerialNum" +#define SCAN_FWVERSION "FWVersion" +#define SCAN_HRATIO "HRatio" +#define SCAN_VRATIO "VRatio" +#define SCAN_SLEEPTIME "SleepTime" +#define SCAN_TOKEN "ScannerToken" +#define SCAN_SPEEDMODE "SpeedMode" +#define SCAN_VID "VID" +#define SCAN_PID "PID" + +#define TOKEN_DEFAULT " " +#define FWVERSION "G345230918" +#define SERIALNUM "HS6010A38001P1" +JsonConfig::JsonConfig() +{ + if (access(SCANNER_SCAN_INFO_PATH, F_OK) == -1) //不存在 + { + + } +} +JsonConfig::JsonConfig(ConfigType type) : m_cfgType(type) +{ +} + +JsonConfig::~JsonConfig() +{ +} + + + + +ScannerScanInfo JsonConfig::GetScanInfo() +{ + ScannerScanInfo info; + if (access(SCANNER_SCAN_INFO_PATH, F_OK) != 0) + { + return info; + } + std::ifstream i(SCANNER_SCAN_INFO_PATH); + auto pos = i.tellg(); + i.seekg(0, ios::end); + if(i.tellg()<=2) + { + return info; + } + json j; + i.seekg(pos); + { + std::lock_guard m_c(m_lock); + i >> j; + i.close(); + } + + auto &jobject = j[SCAN_INFO_TITLE]; + + if (jobject.contains(SCAN_TOTAL)) + jobject[SCAN_TOTAL].get_to(info.TotalScanned); + else + info.TotalScanned = 0; + + if (jobject.contains(SCAN_ROLLERNUM)) + jobject[SCAN_ROLLERNUM].get_to(info.RollerNum); + else + info.RollerNum = 0; + + if (jobject.contains(SCAN_CUONUM)) + jobject[SCAN_CUONUM].get_to(info.CuoNum); + else + info.CuoNum = 0; + + if (jobject.contains(SCAN_JAMINNUM)) + jobject[SCAN_JAMINNUM].get_to(info.JamInNum); + else + info.JamInNum = 0; + + if (jobject.contains(SCAN_JAMOUTNUM)) + jobject[SCAN_JAMOUTNUM].get_to(info.JamOutNum); + else + info.JamOutNum = 0; + + if (jobject.contains(SCAN_DOUNUM)) + jobject[SCAN_DOUNUM].get_to(info.DoubleNum); + else + info.DoubleNum = 0; + + if (jobject.contains(SCAN_ERRORNUM)) + jobject[SCAN_ERRORNUM].get_to(info.ErrorNum); + else + info.ErrorNum = 0; + + if (jobject.contains(SCAN_SERIALNUM)) + jobject[SCAN_SERIALNUM].get_to(info.SerialNum); + else + info.SerialNum = SERIALNUM; + + if (jobject.contains(SCAN_FWVERSION)) + jobject[SCAN_FWVERSION].get_to(info.FWVersion); + + + if (jobject.contains(SCAN_HRATIO)) + jobject[SCAN_HRATIO].get_to(info.HRatio); + else + info.HRatio = 1065353216;//默认 1.0f + + if (jobject.contains(SCAN_VRATIO)) + jobject[SCAN_VRATIO].get_to(info.VRatio); + else + info.VRatio = 1065353216;//默认 1.0f + + if (jobject.contains(SCAN_SLEEPTIME)) + jobject[SCAN_SLEEPTIME].get_to(info.SleepTime); + else + info.SleepTime = 3600;//默认 1.0f + + if(jobject.contains(SCAN_TOKEN)) + jobject[SCAN_TOKEN].get_to(info.Token); + else + { + info.Token=TOKEN_DEFAULT; + } + + if(jobject.contains(SCAN_SPEEDMODE)) + jobject[SCAN_SPEEDMODE].get_to(info.SpeedMode); + else + { + info.SpeedMode = 4; + } + + if(jobject.contains(SCAN_VID)) + jobject[SCAN_VID].get_to(info.VID); + else + { + info.VID = 0x3072; + } + + + if(jobject.contains(SCAN_PID)) + jobject[SCAN_PID].get_to(info.PID); + else + { + #ifdef G400 + info.PID = 0x0400; + #else + info.PID = 0x0300; + #endif + } + return info; +} diff --git a/JsonConfig.h b/sleep_processes_code/JsonConfig.h similarity index 59% rename from JsonConfig.h rename to sleep_processes_code/JsonConfig.h index 746bf28..f8eca73 100644 --- a/JsonConfig.h +++ b/sleep_processes_code/JsonConfig.h @@ -1,10 +1,28 @@ #pragma once #include #include "json.hpp" -#include "scanservices_utils.h" #include #include #include +struct ScannerScanInfo +{ + unsigned int TotalScanned; //扫描总页数 + unsigned int RollerNum; + unsigned int CuoNum; //搓纸总数 + unsigned int JamInNum; //搓纸失败次数 + unsigned int JamOutNum; //卡纸次数 + unsigned int DoubleNum; //双张次数 + unsigned int ErrorNum; //其他异常次数 + unsigned int HRatio; //横向校正系数 + unsigned int VRatio; //纵向校正系数 + unsigned int SleepTime; //休眠时间 单位s + unsigned int SpeedMode; //速率模式 + unsigned int VID; //vid + unsigned short PID; //pid + std::string SerialNum; //序列号 + std::string FWVersion; //固件版本号 + std::string Token; //token 令牌 +}; #define SCANNER_SCAN_INFO_PATH "/mnt/flash-disk/huago/jsonconfig.json" using namespace std; @@ -38,18 +56,10 @@ public: JsonConfig(); JsonConfig(ConfigType type); ~JsonConfig(); - /* - *若返回false 则表示文件不存在或文件读取失败 - */ - // bool ReadParam(FPGAConfigParam& param); - // void WriteParam(FPGAConfigParam& t_param); ScannerScanInfo GetScanInfo(); - map::iterator l_it; - void SaveScanInfo(const ScannerScanInfo& info); + private: - //FPGAConfigParam CreateDefault(); std::mutex m_lock; - ScannerScanInfo CreateDefaultScanInfo(); }; diff --git a/json.hpp b/sleep_processes_code/json.hpp similarity index 100% rename from json.hpp rename to sleep_processes_code/json.hpp diff --git a/sleep_processes_code/main.cpp b/sleep_processes_code/main.cpp new file mode 100644 index 0000000..aa0b8c6 --- /dev/null +++ b/sleep_processes_code/main.cpp @@ -0,0 +1,101 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include"JsonConfig.h" +#define erroe_status -1 +#define start_sleep 1 +#define close_sleep 0 + +int readfile(int fd, char* buf,int num ) +{ + lseek(fd, 0, SEEK_SET); + int ret = read(fd, buf, num); + if (ret == -1) + { + printf("readfile error:%s\r\n",strerror(ret)); + return erroe_status; + } + if (ret == 0) + { + printf("readfile error:%s\r\n","service connection is lost"); + return erroe_status; + } + printf("sleep processes len :%d\r\n",ret); + return atoi(buf); +} +void start_enter_lowpwoer(int time) +{ + int seconds = time; + + if(time < 0 || time < 180) + seconds = 180; + else + seconds = time; + + std::string str="sh /mnt/flash-disk/countdown.sh start 0 0 "+std::to_string(seconds) + " &"; + printf("start_enter_lowpwoer %s \n",str.c_str()); + + int ret = system(str.c_str()); +} +void stop_countdown() +{ + int ret = system("sh /mnt/flash-disk/killtimer.sh"); + printf("system stop_countdown :%d\r\n",ret); +} + +int main(int argc, char *argv[]) +{ + int fd = -1; + int ret = 0; + pollfd pfd; + ret = mkfifo("/home/root/dev/sleep", 0666); + if(ret != 0) + { + perror("/home/root/dev/sleep"); + } + + printf("before open\n"); + fd = open("/home/root/dev/sleep", O_RDONLY);//等着只写 + if(fd < 0) + { + perror("open fifo"); + } + + printf("after open\n"); + + char buffer[12]; + JsonConfig js; + + + while (true) + { + ret = readfile(fd,buffer,sizeof(buffer)); + printf("while read buf:[%d]\n", ret); + if (ret == -1) + { + system("sh /mnt/flash-disk/leds.sh 1"); + sleep(3); + continue; + } + + if (ret == 1) + { + ScannerScanInfo info = js.GetScanInfo(); + stop_countdown(); + sleep(3); + start_enter_lowpwoer(info.SleepTime); + } + else + stop_countdown(); + + } + close(fd); + return 0; +} + + diff --git a/test.cpp b/test.cpp deleted file mode 100644 index 2d9c60a..0000000 --- a/test.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define VIDPID_PATH "/usr/local/bin/mtpd.sh" - -/* - * FunctionName: main - * Description: - */ -int main01(int argc, char *argv[]) -{ - int ret = 0; - printf("argc = %d \n", argc); - if (argc != 3) - { - return -1; - } - unsigned int i_vid = atoi(argv[1]); - unsigned int i_pid = atoi(argv[2]); - printf("arg0 = %d arg1=%d \n", i_vid, i_pid); - char buf_vid[5] ={0}; - char buf_pid[5] ={0}; - buf_vid[4]='\0'; - buf_pid[4]='\0'; - sprintf(buf_vid,"%04x",i_vid); - sprintf(buf_pid,"%04x",i_pid); - printf("buf_vid = %s buf_pid=%s \n", buf_vid, buf_pid); - if (i_pid > 0 && i_vid > 0) - { - FILE *fd; - - fd = fopen(VIDPID_PATH, "rb+"); - if (!fd) { - printf( "error open /usr/local/bin/mtp.sh...\n"); - return -1; - } - else { - printf( "open %s scuess.fd = %d\n", VIDPID_PATH,fd); - } - - /*set vid*/ - fseek(fd , 0x18e , SEEK_SET); - ret = fwrite(buf_vid, 1, 4, fd); - - /*set pid*/ - fseek(fd , 0x1c8 , SEEK_SET); - ret = fwrite(buf_pid, 1, 4, fd); - - fclose(fd); - return 0; - } - - return -1; -} /* ---------- end of function main ---------- */ diff --git a/BlockingQueue.h b/zynq_7010_code/BlockingQueue.h similarity index 100% rename from BlockingQueue.h rename to zynq_7010_code/BlockingQueue.h diff --git a/CImageMerge.cpp b/zynq_7010_code/CImageMerge.cpp similarity index 100% rename from CImageMerge.cpp rename to zynq_7010_code/CImageMerge.cpp diff --git a/CImageMerge.h b/zynq_7010_code/CImageMerge.h similarity index 100% rename from CImageMerge.h rename to zynq_7010_code/CImageMerge.h diff --git a/zynq_7010_code/CMakeLists.txt b/zynq_7010_code/CMakeLists.txt index 03d32ec..1cc394d 100644 --- a/zynq_7010_code/CMakeLists.txt +++ b/zynq_7010_code/CMakeLists.txt @@ -1,26 +1,58 @@ cmake_minimum_required(VERSION 3.0.0) -project(sleep_processes) +project(scanservice) add_compile_options(-std=c++14) #set (CMAKE_GENERATOR "/home/holdtecs/zzm-linux/rk3288-linux/prebuilts/gcc/linux-x86/arm/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++") +#交叉编译配置 +# set(CMAKE_SYSTEM_NAME Linux) +# set(CMAKE_SYSTEM_PROCESSOR arm) +#可选,配置roofs和安装路径如果存在 +#set(linux_sdk_path /home/holdtecs/zzm-linux/rk3288-linux) +#set(linux_sdk_path /mnt/disk2/linux-rhx/rk3288-linux) +#set(CMAKE_SYSROOT ${linux_sdk_path}/buildroot/output/rockchip_rk3288/host/arm-buildroot-linux-gnueabihf/sysroot) +# set(CMAKE_STAGING_PREFIX ${PROJECT_SOURCE_DIR}/install) +#编译工具配置 +#set(tools ${linux_sdk_path}/prebuilts/gcc/linux-x86/arm/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf) +# set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) +# set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) +# set(CMAKE_LIBRARY_ARCHITECTURE arm) +add_subdirectory(fpga) +set(-mfloat-abi=hard) +# set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +# set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +# set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -fvectorize") +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -fvectorize") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") - +set(OpenCV_DIR /home/modehua/sdk/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/usr/include/opencv4/) +#set(OpenCV_DIR /home/holdtecs/zzm-linux/fs/usr/lib) +#find_package( OpenCV 3 REQUIRED ) +include_directories( ${OpenCV_INCLUDE_DIRS} ) FILE(GLOB SRC "*.cpp" "*.h" "*.c") FILE(GLOB IMAGEPRO "imageprocess/*.h" "imageprocess/*.cpp" ) FILE(GLOB FPGA "fpga/*.h" "fpga/*.cpp" ) - +# message(STATUS "SRC:" ${SRC}) +# message(STATUS "IMAGEPRO:" ${IMAGEPRO}) + #message(STATUS "FPGA:" ${FPGA}) set(CMAKE_BUILD_TYPE "Release") + include_directories( + fpga + imageprocess + imageprocess/include + #/home/modehua/sdk/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/usr/include/opencv4/ + ) add_executable(${PROJECT_NAME} ${SRC}) @@ -36,7 +68,11 @@ add_custom_command(TARGET ${PROJECT_NAME} set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "-s") - +target_link_libraries(${PROJECT_NAME} ${PROJECT_BINARY_DIR}/bin/libfpgaupdate.a) target_link_libraries(${PROJECT_NAME} opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs turbojpeg pthread ) target_link_libraries(${PROJECT_NAME} pthread ) +target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/fpga + /home/modehua/sdk/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/usr/include/opencv4/ +) \ No newline at end of file diff --git a/CameraParam.h b/zynq_7010_code/CameraParam.h similarity index 100% rename from CameraParam.h rename to zynq_7010_code/CameraParam.h diff --git a/CameraParams.h b/zynq_7010_code/CameraParams.h similarity index 100% rename from CameraParams.h rename to zynq_7010_code/CameraParams.h diff --git a/CorrectParam.cpp b/zynq_7010_code/CorrectParam.cpp similarity index 100% rename from CorrectParam.cpp rename to zynq_7010_code/CorrectParam.cpp diff --git a/CorrectParam.h b/zynq_7010_code/CorrectParam.h similarity index 100% rename from CorrectParam.h rename to zynq_7010_code/CorrectParam.h diff --git a/CuoZhiMotor.cpp b/zynq_7010_code/CuoZhiMotor.cpp similarity index 100% rename from CuoZhiMotor.cpp rename to zynq_7010_code/CuoZhiMotor.cpp diff --git a/CuoZhiMotor.h b/zynq_7010_code/CuoZhiMotor.h similarity index 100% rename from CuoZhiMotor.h rename to zynq_7010_code/CuoZhiMotor.h diff --git a/DevUtil.cpp b/zynq_7010_code/DevUtil.cpp similarity index 100% rename from DevUtil.cpp rename to zynq_7010_code/DevUtil.cpp diff --git a/DevUtil.h b/zynq_7010_code/DevUtil.h similarity index 100% rename from DevUtil.h rename to zynq_7010_code/DevUtil.h diff --git a/FsmState.cpp b/zynq_7010_code/FsmState.cpp similarity index 100% rename from FsmState.cpp rename to zynq_7010_code/FsmState.cpp diff --git a/FsmState.h b/zynq_7010_code/FsmState.h similarity index 100% rename from FsmState.h rename to zynq_7010_code/FsmState.h diff --git a/Gpio.cpp b/zynq_7010_code/Gpio.cpp similarity index 100% rename from Gpio.cpp rename to zynq_7010_code/Gpio.cpp diff --git a/Gpio.h b/zynq_7010_code/Gpio.h similarity index 100% rename from Gpio.h rename to zynq_7010_code/Gpio.h diff --git a/HCamDevice.cpp b/zynq_7010_code/HCamDevice.cpp similarity index 100% rename from HCamDevice.cpp rename to zynq_7010_code/HCamDevice.cpp diff --git a/HCamDevice.h b/zynq_7010_code/HCamDevice.h similarity index 100% rename from HCamDevice.h rename to zynq_7010_code/HCamDevice.h diff --git a/HGUsb.cpp b/zynq_7010_code/HGUsb.cpp similarity index 100% rename from HGUsb.cpp rename to zynq_7010_code/HGUsb.cpp diff --git a/HGUsb.h b/zynq_7010_code/HGUsb.h similarity index 100% rename from HGUsb.h rename to zynq_7010_code/HGUsb.h diff --git a/ICapturer.h b/zynq_7010_code/ICapturer.h similarity index 100% rename from ICapturer.h rename to zynq_7010_code/ICapturer.h diff --git a/IScanner.h b/zynq_7010_code/IScanner.h similarity index 100% rename from IScanner.h rename to zynq_7010_code/IScanner.h diff --git a/Jpegcompress.cpp b/zynq_7010_code/Jpegcompress.cpp similarity index 100% rename from Jpegcompress.cpp rename to zynq_7010_code/Jpegcompress.cpp diff --git a/Jpegcompress.h b/zynq_7010_code/Jpegcompress.h similarity index 100% rename from Jpegcompress.h rename to zynq_7010_code/Jpegcompress.h diff --git a/zynq_7010_code/JsonConfig.cpp b/zynq_7010_code/JsonConfig.cpp index 9de7589..b43c775 100644 --- a/zynq_7010_code/JsonConfig.cpp +++ b/zynq_7010_code/JsonConfig.cpp @@ -22,13 +22,12 @@ #define SCAN_PID "PID" #define TOKEN_DEFAULT " " -#define FWVERSION "G345230918" -#define SERIALNUM "HS6010A38001P1" JsonConfig::JsonConfig() { if (access(SCANNER_SCAN_INFO_PATH, F_OK) == -1) //不存在 { - + ScannerScanInfo defaultinfo = CreateDefaultScanInfo(); + SaveScanInfo(defaultinfo); } } JsonConfig::JsonConfig(ConfigType type) : m_cfgType(type) @@ -39,14 +38,104 @@ JsonConfig::~JsonConfig() { } +// bool JsonConfig::ReadParam(FPGAConfigParam ¶m) +// { +// bool ret = false; +// if (access(cfgPaths[m_cfgType].c_str(), F_OK) == -1) +// { +// return ret; +// } +// std::ifstream i(cfgPaths[m_cfgType]); +// json j; +// i >> j; +// auto &jobject = j[cfgPrefix[m_cfgType]]; +// jobject[cfgPrefix[m_cfgType] + "ExposureF"].get_to(param.ExposureF); +// jobject[cfgPrefix[m_cfgType] + "ExposureB"].get_to(param.ExposureB); +// jobject[cfgPrefix[m_cfgType] + "GainF"].get_to(param.GainF); +// jobject[cfgPrefix[m_cfgType] + "GainB"].get_to(param.GainB); +// jobject[cfgPrefix[m_cfgType] + "OffsetF"].get_to(param.OffsetF); +// jobject[cfgPrefix[m_cfgType] + "OffsetB"].get_to(param.OffsetB); +// return ret; +// } +// void JsonConfig::WriteParam(FPGAConfigParam &t_param) +// { +// FPGAConfigParam param; +// if (access(cfgPaths[m_cfgType].c_str(), F_OK) == -1) +// { +// LOG("Not found config %s \n", cfgPaths[m_cfgType].c_str()); +// param = CreateDefault(); +// } +// else +// param = t_param; +// LOG("start save %s \n", cfgPaths[m_cfgType].c_str()); +// json m_json; +// auto &jobject = m_json[cfgPrefix[m_cfgType]]; +// jobject[cfgPrefix[m_cfgType] + "ExposureF"] = {param.ExposureF[0], param.ExposureF[1], param.ExposureF[2]}; +// jobject[cfgPrefix[m_cfgType] + "ExposureB"] = {param.ExposureB[0], param.ExposureB[1], param.ExposureB[2]}; +// jobject[cfgPrefix[m_cfgType] + "GainF"] = {param.GainF[0], param.GainF[1], param.GainF[2], param.GainF[3], param.GainF[4], param.GainF[5]}; +// jobject[cfgPrefix[m_cfgType] + "GainB"] = {param.GainB[0], param.GainB[1], param.GainB[2], param.GainB[3], param.GainB[4], param.GainB[5]}; +// jobject[cfgPrefix[m_cfgType] + "OffsetF"] = {param.OffsetF[0], param.OffsetF[1], param.OffsetF[2], param.OffsetF[3], param.OffsetF[4], param.OffsetF[5]}; +// jobject[cfgPrefix[m_cfgType] + "OffsetB"] = {param.OffsetB[0], param.OffsetB[1], param.OffsetB[2], param.OffsetB[3], param.OffsetB[4], param.OffsetB[5]}; +// std::ofstream o(cfgPaths[m_cfgType]); +// o << std::setw(4) << m_json << std::endl; +// LOG("save config %s down \n", cfgPaths[m_cfgType].c_str()); +// } + +// FPGAConfigParam JsonConfig::CreateDefault() +// { +// std::string savePath = cfgPaths[m_cfgType]; +// FPGAConfigParam param = {0}; +// for (size_t i = 0; i < 3; i++) +// { +// param.ExposureF[i] = 259; +// param.ExposureB[i] = 238; +// } + +// for (size_t i = 0; i < 6; i++) +// { +// param.GainB[i] = 30; +// param.GainF[i] = 30; +// param.OffsetB[i] = param.OffsetF[i] = 119; +// } +// return param; +// } + +ScannerScanInfo JsonConfig::CreateDefaultScanInfo() +{ + ScannerScanInfo info; + info.CuoNum = 0; + info.DoubleNum = 0; + info.ErrorNum = 0; + info.JamInNum = 0; + info.JamOutNum = 0; + info.FWVersion = FWVERSION; + info.SerialNum = SERIALNUM; + info.TotalScanned = 0; + info.RollerNum = 0; + info.HRatio = 1065353216;//(=(float)1.0) + info.VRatio = 1065353216; + info.SleepTime=3600; + info.Token=TOKEN_DEFAULT; + info.SpeedMode = 4; + l_it = mapFradme_SP.find(info.SpeedMode); + info.FWVersion = l_it->second.FWVERSIO; + + info.VID = 0x3072; + info.PID = 0x0300; + + return info; +} ScannerScanInfo JsonConfig::GetScanInfo() { ScannerScanInfo info; if (access(SCANNER_SCAN_INFO_PATH, F_OK) != 0) { + printf("/mnt/flash-disk/huago/jsonconfig.json do not exist!\n"); + info = CreateDefaultScanInfo(); + SaveScanInfo(info); return info; } std::ifstream i(SCANNER_SCAN_INFO_PATH); @@ -54,6 +143,9 @@ ScannerScanInfo JsonConfig::GetScanInfo() i.seekg(0, ios::end); if(i.tellg()<=2) { + printf("/mnt/flash-disk/huago/jsonconfig.json file size < 2!\n"); + info = CreateDefaultScanInfo(); + SaveScanInfo(info); return info; } json j; @@ -108,7 +200,8 @@ ScannerScanInfo JsonConfig::GetScanInfo() if (jobject.contains(SCAN_FWVERSION)) jobject[SCAN_FWVERSION].get_to(info.FWVersion); - + else + info.FWVersion = l_it->second.FWVERSIO; if (jobject.contains(SCAN_HRATIO)) jobject[SCAN_HRATIO].get_to(info.HRatio); @@ -159,3 +252,31 @@ ScannerScanInfo JsonConfig::GetScanInfo() } return info; } + +void JsonConfig::SaveScanInfo(const ScannerScanInfo &info) +{ + json m_json; + auto &jobject = m_json[SCAN_INFO_TITLE]; + jobject[SCAN_TOTAL] = info.TotalScanned; + jobject[SCAN_ROLLERNUM] = info.RollerNum; + jobject[SCAN_CUONUM] = info.CuoNum; + jobject[SCAN_JAMINNUM] = info.JamInNum; + jobject[SCAN_JAMOUTNUM] = info.JamOutNum; + jobject[SCAN_DOUNUM] = info.DoubleNum; + jobject[SCAN_ERRORNUM] = info.ErrorNum; + jobject[SCAN_SERIALNUM] = info.SerialNum; + jobject[SCAN_FWVERSION] = info.FWVersion; + jobject[SCAN_HRATIO]= info.HRatio; + jobject[SCAN_VRATIO] = info.VRatio; + jobject[SCAN_SLEEPTIME] = info.SleepTime; + jobject[SCAN_TOKEN] = info.Token; + jobject[SCAN_SPEEDMODE] = info.SpeedMode; + jobject[SCAN_VID] = info.VID; + jobject[SCAN_PID] = info.PID; + std::lock_guard m_c(m_lock); + std::ofstream o(SCANNER_SCAN_INFO_PATH); + //std::cout< #include "json.hpp" +#include "scanservices_utils.h" #include #include #include -struct ScannerScanInfo -{ - unsigned int TotalScanned; //扫描总页数 - unsigned int RollerNum; - unsigned int CuoNum; //搓纸总数 - unsigned int JamInNum; //搓纸失败次数 - unsigned int JamOutNum; //卡纸次数 - unsigned int DoubleNum; //双张次数 - unsigned int ErrorNum; //其他异常次数 - unsigned int HRatio; //横向校正系数 - unsigned int VRatio; //纵向校正系数 - unsigned int SleepTime; //休眠时间 单位s - unsigned int SpeedMode; //速率模式 - unsigned int VID; //vid - unsigned short PID; //pid - std::string SerialNum; //序列号 - std::string FWVersion; //固件版本号 - std::string Token; //token 令牌 -}; #define SCANNER_SCAN_INFO_PATH "/mnt/flash-disk/huago/jsonconfig.json" using namespace std; @@ -56,10 +38,18 @@ public: JsonConfig(); JsonConfig(ConfigType type); ~JsonConfig(); + /* + *若返回false 则表示文件不存在或文件读取失败 + */ + // bool ReadParam(FPGAConfigParam& param); + // void WriteParam(FPGAConfigParam& t_param); ScannerScanInfo GetScanInfo(); - + map::iterator l_it; + void SaveScanInfo(const ScannerScanInfo& info); private: + //FPGAConfigParam CreateDefault(); std::mutex m_lock; + ScannerScanInfo CreateDefaultScanInfo(); }; diff --git a/Keyboard.cpp b/zynq_7010_code/Keyboard.cpp similarity index 100% rename from Keyboard.cpp rename to zynq_7010_code/Keyboard.cpp diff --git a/Keyboard.h b/zynq_7010_code/Keyboard.h similarity index 100% rename from Keyboard.h rename to zynq_7010_code/Keyboard.h diff --git a/Led.cpp b/zynq_7010_code/Led.cpp similarity index 100% rename from Led.cpp rename to zynq_7010_code/Led.cpp diff --git a/Led.h b/zynq_7010_code/Led.h similarity index 100% rename from Led.h rename to zynq_7010_code/Led.h diff --git a/MemoryInfo.cpp b/zynq_7010_code/MemoryInfo.cpp similarity index 100% rename from MemoryInfo.cpp rename to zynq_7010_code/MemoryInfo.cpp diff --git a/MemoryInfo.h b/zynq_7010_code/MemoryInfo.h similarity index 100% rename from MemoryInfo.h rename to zynq_7010_code/MemoryInfo.h diff --git a/Motor.cpp b/zynq_7010_code/Motor.cpp similarity index 100% rename from Motor.cpp rename to zynq_7010_code/Motor.cpp diff --git a/Motor.h b/zynq_7010_code/Motor.h similarity index 100% rename from Motor.h rename to zynq_7010_code/Motor.h diff --git a/MotorConfig.cpp b/zynq_7010_code/MotorConfig.cpp similarity index 100% rename from MotorConfig.cpp rename to zynq_7010_code/MotorConfig.cpp diff --git a/MotorConfig.h b/zynq_7010_code/MotorConfig.h similarity index 100% rename from MotorConfig.h rename to zynq_7010_code/MotorConfig.h diff --git a/Motordef.h b/zynq_7010_code/Motordef.h similarity index 100% rename from Motordef.h rename to zynq_7010_code/Motordef.h diff --git a/MultiFrameCapture.cpp b/zynq_7010_code/MultiFrameCapture.cpp similarity index 100% rename from MultiFrameCapture.cpp rename to zynq_7010_code/MultiFrameCapture.cpp diff --git a/MultiFrameCapture.h b/zynq_7010_code/MultiFrameCapture.h similarity index 100% rename from MultiFrameCapture.h rename to zynq_7010_code/MultiFrameCapture.h diff --git a/PanelLeds.cpp b/zynq_7010_code/PanelLeds.cpp similarity index 100% rename from PanelLeds.cpp rename to zynq_7010_code/PanelLeds.cpp diff --git a/PanelLeds.h b/zynq_7010_code/PanelLeds.h similarity index 100% rename from PanelLeds.h rename to zynq_7010_code/PanelLeds.h diff --git a/Properties.cpp b/zynq_7010_code/Properties.cpp similarity index 100% rename from Properties.cpp rename to zynq_7010_code/Properties.cpp diff --git a/Properties.h b/zynq_7010_code/Properties.h similarity index 100% rename from Properties.h rename to zynq_7010_code/Properties.h diff --git a/PropertiesException.h b/zynq_7010_code/PropertiesException.h similarity index 100% rename from PropertiesException.h rename to zynq_7010_code/PropertiesException.h diff --git a/PropertiesParser.cpp b/zynq_7010_code/PropertiesParser.cpp similarity index 100% rename from PropertiesParser.cpp rename to zynq_7010_code/PropertiesParser.cpp diff --git a/PropertiesParser.h b/zynq_7010_code/PropertiesParser.h similarity index 100% rename from PropertiesParser.h rename to zynq_7010_code/PropertiesParser.h diff --git a/PropertiesUtils.cpp b/zynq_7010_code/PropertiesUtils.cpp similarity index 100% rename from PropertiesUtils.cpp rename to zynq_7010_code/PropertiesUtils.cpp diff --git a/PropertiesUtils.h b/zynq_7010_code/PropertiesUtils.h similarity index 100% rename from PropertiesUtils.h rename to zynq_7010_code/PropertiesUtils.h diff --git a/PropertyNotFoundException.h b/zynq_7010_code/PropertyNotFoundException.h similarity index 100% rename from PropertyNotFoundException.h rename to zynq_7010_code/PropertyNotFoundException.h diff --git a/Pwm.cpp b/zynq_7010_code/Pwm.cpp similarity index 100% rename from Pwm.cpp rename to zynq_7010_code/Pwm.cpp diff --git a/Pwm.h b/zynq_7010_code/Pwm.h similarity index 100% rename from Pwm.h rename to zynq_7010_code/Pwm.h diff --git a/ScanConfig.cpp b/zynq_7010_code/ScanConfig.cpp similarity index 100% rename from ScanConfig.cpp rename to zynq_7010_code/ScanConfig.cpp diff --git a/ScanConfig.h b/zynq_7010_code/ScanConfig.h similarity index 100% rename from ScanConfig.h rename to zynq_7010_code/ScanConfig.h diff --git a/Scanner.cpp b/zynq_7010_code/Scanner.cpp similarity index 100% rename from Scanner.cpp rename to zynq_7010_code/Scanner.cpp diff --git a/Scanner.h b/zynq_7010_code/Scanner.h similarity index 100% rename from Scanner.h rename to zynq_7010_code/Scanner.h diff --git a/Sensor.cpp b/zynq_7010_code/Sensor.cpp similarity index 100% rename from Sensor.cpp rename to zynq_7010_code/Sensor.cpp diff --git a/Sensor.h b/zynq_7010_code/Sensor.h similarity index 100% rename from Sensor.h rename to zynq_7010_code/Sensor.h diff --git a/SysInforTool.cpp b/zynq_7010_code/SysInforTool.cpp similarity index 100% rename from SysInforTool.cpp rename to zynq_7010_code/SysInforTool.cpp diff --git a/SysInforTool.h b/zynq_7010_code/SysInforTool.h similarity index 100% rename from SysInforTool.h rename to zynq_7010_code/SysInforTool.h diff --git a/ThreadPool.h b/zynq_7010_code/ThreadPool.h similarity index 100% rename from ThreadPool.h rename to zynq_7010_code/ThreadPool.h diff --git a/TypeIO.cpp b/zynq_7010_code/TypeIO.cpp similarity index 100% rename from TypeIO.cpp rename to zynq_7010_code/TypeIO.cpp diff --git a/TypeIO.h b/zynq_7010_code/TypeIO.h similarity index 100% rename from TypeIO.h rename to zynq_7010_code/TypeIO.h diff --git a/USBProtocol.h b/zynq_7010_code/USBProtocol.h similarity index 100% rename from USBProtocol.h rename to zynq_7010_code/USBProtocol.h diff --git a/UsbEndpoint.cpp b/zynq_7010_code/UsbEndpoint.cpp similarity index 100% rename from UsbEndpoint.cpp rename to zynq_7010_code/UsbEndpoint.cpp diff --git a/UsbEndpoint.h b/zynq_7010_code/UsbEndpoint.h similarity index 100% rename from UsbEndpoint.h rename to zynq_7010_code/UsbEndpoint.h diff --git a/UsbScanner.cpp b/zynq_7010_code/UsbScanner.cpp similarity index 100% rename from UsbScanner.cpp rename to zynq_7010_code/UsbScanner.cpp diff --git a/UsbScanner.h b/zynq_7010_code/UsbScanner.h similarity index 100% rename from UsbScanner.h rename to zynq_7010_code/UsbScanner.h diff --git a/UsbmsgHandler.cpp b/zynq_7010_code/UsbmsgHandler.cpp similarity index 100% rename from UsbmsgHandler.cpp rename to zynq_7010_code/UsbmsgHandler.cpp diff --git a/UsbmsgHandler.h b/zynq_7010_code/UsbmsgHandler.h similarity index 100% rename from UsbmsgHandler.h rename to zynq_7010_code/UsbmsgHandler.h diff --git a/ZouZhiMotor.cpp b/zynq_7010_code/ZouZhiMotor.cpp similarity index 100% rename from ZouZhiMotor.cpp rename to zynq_7010_code/ZouZhiMotor.cpp diff --git a/ZouZhiMotor.h b/zynq_7010_code/ZouZhiMotor.h similarity index 100% rename from ZouZhiMotor.h rename to zynq_7010_code/ZouZhiMotor.h diff --git a/autoevent.hpp b/zynq_7010_code/autoevent.hpp similarity index 100% rename from autoevent.hpp rename to zynq_7010_code/autoevent.hpp diff --git a/bmp.cpp b/zynq_7010_code/bmp.cpp similarity index 100% rename from bmp.cpp rename to zynq_7010_code/bmp.cpp diff --git a/bmp.h b/zynq_7010_code/bmp.h similarity index 100% rename from bmp.h rename to zynq_7010_code/bmp.h diff --git a/buildconf.h b/zynq_7010_code/buildconf.h similarity index 100% rename from buildconf.h rename to zynq_7010_code/buildconf.h diff --git a/camtp.h b/zynq_7010_code/camtp.h similarity index 100% rename from camtp.h rename to zynq_7010_code/camtp.h diff --git a/correct_ultis.cpp b/zynq_7010_code/correct_ultis.cpp similarity index 100% rename from correct_ultis.cpp rename to zynq_7010_code/correct_ultis.cpp diff --git a/correct_ultis.h b/zynq_7010_code/correct_ultis.h similarity index 100% rename from correct_ultis.h rename to zynq_7010_code/correct_ultis.h diff --git a/countdown.sh b/zynq_7010_code/countdown.sh similarity index 100% rename from countdown.sh rename to zynq_7010_code/countdown.sh diff --git a/default_cfg.h b/zynq_7010_code/default_cfg.h similarity index 100% rename from default_cfg.h rename to zynq_7010_code/default_cfg.h diff --git a/filetools.h b/zynq_7010_code/filetools.h similarity index 100% rename from filetools.h rename to zynq_7010_code/filetools.h diff --git a/fpga/CMakeLists.txt b/zynq_7010_code/fpga/CMakeLists.txt similarity index 100% rename from fpga/CMakeLists.txt rename to zynq_7010_code/fpga/CMakeLists.txt diff --git a/zynq_7010_code/fpga/bin/libfpgaupdate.a b/zynq_7010_code/fpga/bin/libfpgaupdate.a new file mode 100644 index 0000000..47dcd36 Binary files /dev/null and b/zynq_7010_code/fpga/bin/libfpgaupdate.a differ diff --git a/fpga/build/CMakeCache.txt b/zynq_7010_code/fpga/build/CMakeCache.txt similarity index 100% rename from fpga/build/CMakeCache.txt rename to zynq_7010_code/fpga/build/CMakeCache.txt diff --git a/fpga/build/CMakeFiles/3.18.2/CMakeCCompiler.cmake b/zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CMakeCCompiler.cmake similarity index 100% rename from fpga/build/CMakeFiles/3.18.2/CMakeCCompiler.cmake rename to zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CMakeCCompiler.cmake diff --git a/fpga/build/CMakeFiles/3.18.2/CMakeCXXCompiler.cmake b/zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CMakeCXXCompiler.cmake similarity index 100% rename from fpga/build/CMakeFiles/3.18.2/CMakeCXXCompiler.cmake rename to zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CMakeCXXCompiler.cmake diff --git a/fpga/build/CMakeFiles/3.18.2/CMakeDetermineCompilerABI_C.bin b/zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CMakeDetermineCompilerABI_C.bin similarity index 100% rename from fpga/build/CMakeFiles/3.18.2/CMakeDetermineCompilerABI_C.bin rename to zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CMakeDetermineCompilerABI_C.bin diff --git a/fpga/build/CMakeFiles/3.18.2/CMakeDetermineCompilerABI_CXX.bin b/zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CMakeDetermineCompilerABI_CXX.bin similarity index 100% rename from fpga/build/CMakeFiles/3.18.2/CMakeDetermineCompilerABI_CXX.bin rename to zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CMakeDetermineCompilerABI_CXX.bin diff --git a/fpga/build/CMakeFiles/3.18.2/CMakeSystem.cmake b/zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CMakeSystem.cmake similarity index 100% rename from fpga/build/CMakeFiles/3.18.2/CMakeSystem.cmake rename to zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CMakeSystem.cmake diff --git a/fpga/build/CMakeFiles/3.18.2/CompilerIdC/CMakeCCompilerId.c b/zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CompilerIdC/CMakeCCompilerId.c similarity index 100% rename from fpga/build/CMakeFiles/3.18.2/CompilerIdC/CMakeCCompilerId.c rename to zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CompilerIdC/CMakeCCompilerId.c diff --git a/fpga/build/CMakeFiles/3.18.2/CompilerIdC/a.out b/zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CompilerIdC/a.out similarity index 100% rename from fpga/build/CMakeFiles/3.18.2/CompilerIdC/a.out rename to zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CompilerIdC/a.out diff --git a/fpga/build/CMakeFiles/3.18.2/CompilerIdCXX/CMakeCXXCompilerId.cpp b/zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CompilerIdCXX/CMakeCXXCompilerId.cpp similarity index 100% rename from fpga/build/CMakeFiles/3.18.2/CompilerIdCXX/CMakeCXXCompilerId.cpp rename to zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CompilerIdCXX/CMakeCXXCompilerId.cpp diff --git a/fpga/build/CMakeFiles/3.18.2/CompilerIdCXX/a.out b/zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CompilerIdCXX/a.out similarity index 100% rename from fpga/build/CMakeFiles/3.18.2/CompilerIdCXX/a.out rename to zynq_7010_code/fpga/build/CMakeFiles/3.18.2/CompilerIdCXX/a.out diff --git a/fpga/build/CMakeFiles/CMakeDirectoryInformation.cmake b/zynq_7010_code/fpga/build/CMakeFiles/CMakeDirectoryInformation.cmake similarity index 100% rename from fpga/build/CMakeFiles/CMakeDirectoryInformation.cmake rename to zynq_7010_code/fpga/build/CMakeFiles/CMakeDirectoryInformation.cmake diff --git a/fpga/build/CMakeFiles/CMakeOutput.log b/zynq_7010_code/fpga/build/CMakeFiles/CMakeOutput.log similarity index 100% rename from fpga/build/CMakeFiles/CMakeOutput.log rename to zynq_7010_code/fpga/build/CMakeFiles/CMakeOutput.log diff --git a/fpga/build/CMakeFiles/Makefile.cmake b/zynq_7010_code/fpga/build/CMakeFiles/Makefile.cmake similarity index 100% rename from fpga/build/CMakeFiles/Makefile.cmake rename to zynq_7010_code/fpga/build/CMakeFiles/Makefile.cmake diff --git a/fpga/build/CMakeFiles/Makefile2 b/zynq_7010_code/fpga/build/CMakeFiles/Makefile2 similarity index 100% rename from fpga/build/CMakeFiles/Makefile2 rename to zynq_7010_code/fpga/build/CMakeFiles/Makefile2 diff --git a/fpga/build/CMakeFiles/TargetDirectories.txt b/zynq_7010_code/fpga/build/CMakeFiles/TargetDirectories.txt similarity index 100% rename from fpga/build/CMakeFiles/TargetDirectories.txt rename to zynq_7010_code/fpga/build/CMakeFiles/TargetDirectories.txt diff --git a/fpga/build/CMakeFiles/cmake.check_cache b/zynq_7010_code/fpga/build/CMakeFiles/cmake.check_cache similarity index 100% rename from fpga/build/CMakeFiles/cmake.check_cache rename to zynq_7010_code/fpga/build/CMakeFiles/cmake.check_cache diff --git a/fpga/build/CMakeFiles/fpgaupdate.dir/C.includecache b/zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/C.includecache similarity index 100% rename from fpga/build/CMakeFiles/fpgaupdate.dir/C.includecache rename to zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/C.includecache diff --git a/fpga/build/CMakeFiles/fpgaupdate.dir/CXX.includecache b/zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/CXX.includecache similarity index 100% rename from fpga/build/CMakeFiles/fpgaupdate.dir/CXX.includecache rename to zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/CXX.includecache diff --git a/fpga/build/CMakeFiles/fpgaupdate.dir/DependInfo.cmake b/zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/DependInfo.cmake similarity index 100% rename from fpga/build/CMakeFiles/fpgaupdate.dir/DependInfo.cmake rename to zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/DependInfo.cmake diff --git a/fpga/build/CMakeFiles/fpgaupdate.dir/build.make b/zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/build.make similarity index 100% rename from fpga/build/CMakeFiles/fpgaupdate.dir/build.make rename to zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/build.make diff --git a/fpga/build/CMakeFiles/fpgaupdate.dir/cmake_clean.cmake b/zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/cmake_clean.cmake similarity index 100% rename from fpga/build/CMakeFiles/fpgaupdate.dir/cmake_clean.cmake rename to zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/cmake_clean.cmake diff --git a/fpga/build/CMakeFiles/fpgaupdate.dir/cmake_clean_target.cmake b/zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/cmake_clean_target.cmake similarity index 100% rename from fpga/build/CMakeFiles/fpgaupdate.dir/cmake_clean_target.cmake rename to zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/cmake_clean_target.cmake diff --git a/fpga/build/CMakeFiles/fpgaupdate.dir/depend.internal b/zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/depend.internal similarity index 100% rename from fpga/build/CMakeFiles/fpgaupdate.dir/depend.internal rename to zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/depend.internal diff --git a/fpga/build/CMakeFiles/fpgaupdate.dir/depend.make b/zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/depend.make similarity index 100% rename from fpga/build/CMakeFiles/fpgaupdate.dir/depend.make rename to zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/depend.make diff --git a/fpga/build/CMakeFiles/fpgaupdate.dir/flags.make b/zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/flags.make similarity index 100% rename from fpga/build/CMakeFiles/fpgaupdate.dir/flags.make rename to zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/flags.make diff --git a/fpga/build/CMakeFiles/fpgaupdate.dir/fpgacontrol.o b/zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/fpgacontrol.o similarity index 100% rename from fpga/build/CMakeFiles/fpgaupdate.dir/fpgacontrol.o rename to zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/fpgacontrol.o diff --git a/fpga/build/CMakeFiles/fpgaupdate.dir/libmtd.o b/zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/libmtd.o similarity index 100% rename from fpga/build/CMakeFiles/fpgaupdate.dir/libmtd.o rename to zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/libmtd.o diff --git a/fpga/build/CMakeFiles/fpgaupdate.dir/libmtd_legacy.o b/zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/libmtd_legacy.o similarity index 100% rename from fpga/build/CMakeFiles/fpgaupdate.dir/libmtd_legacy.o rename to zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/libmtd_legacy.o diff --git a/fpga/build/CMakeFiles/fpgaupdate.dir/link.txt b/zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/link.txt similarity index 100% rename from fpga/build/CMakeFiles/fpgaupdate.dir/link.txt rename to zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/link.txt diff --git a/fpga/build/CMakeFiles/fpgaupdate.dir/progress.make b/zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/progress.make similarity index 100% rename from fpga/build/CMakeFiles/fpgaupdate.dir/progress.make rename to zynq_7010_code/fpga/build/CMakeFiles/fpgaupdate.dir/progress.make diff --git a/fpga/build/CMakeFiles/progress.marks b/zynq_7010_code/fpga/build/CMakeFiles/progress.marks similarity index 100% rename from fpga/build/CMakeFiles/progress.marks rename to zynq_7010_code/fpga/build/CMakeFiles/progress.marks diff --git a/fpga/build/Makefile b/zynq_7010_code/fpga/build/Makefile similarity index 100% rename from fpga/build/Makefile rename to zynq_7010_code/fpga/build/Makefile diff --git a/fpga/build/cmake_install.cmake b/zynq_7010_code/fpga/build/cmake_install.cmake similarity index 100% rename from fpga/build/cmake_install.cmake rename to zynq_7010_code/fpga/build/cmake_install.cmake diff --git a/fpga/fpgacontrol.cpp b/zynq_7010_code/fpga/fpgacontrol.cpp similarity index 100% rename from fpga/fpgacontrol.cpp rename to zynq_7010_code/fpga/fpgacontrol.cpp diff --git a/fpga/fpgacontrol.h b/zynq_7010_code/fpga/fpgacontrol.h similarity index 100% rename from fpga/fpgacontrol.h rename to zynq_7010_code/fpga/fpgacontrol.h diff --git a/fpga/libmtd.c b/zynq_7010_code/fpga/libmtd.c similarity index 100% rename from fpga/libmtd.c rename to zynq_7010_code/fpga/libmtd.c diff --git a/fpga/libmtd.h b/zynq_7010_code/fpga/libmtd.h similarity index 100% rename from fpga/libmtd.h rename to zynq_7010_code/fpga/libmtd.h diff --git a/fpga/libmtd_common.h b/zynq_7010_code/fpga/libmtd_common.h similarity index 100% rename from fpga/libmtd_common.h rename to zynq_7010_code/fpga/libmtd_common.h diff --git a/fpga/libmtd_int.h b/zynq_7010_code/fpga/libmtd_int.h similarity index 100% rename from fpga/libmtd_int.h rename to zynq_7010_code/fpga/libmtd_int.h diff --git a/fpga/libmtd_legacy.c b/zynq_7010_code/fpga/libmtd_legacy.c similarity index 100% rename from fpga/libmtd_legacy.c rename to zynq_7010_code/fpga/libmtd_legacy.c diff --git a/fpga/libmtd_xalloc.h b/zynq_7010_code/fpga/libmtd_xalloc.h similarity index 100% rename from fpga/libmtd_xalloc.h rename to zynq_7010_code/fpga/libmtd_xalloc.h diff --git a/fpgacontrol.cpp b/zynq_7010_code/fpgacontrol.cpp similarity index 100% rename from fpgacontrol.cpp rename to zynq_7010_code/fpgacontrol.cpp diff --git a/fpgacontrol.h b/zynq_7010_code/fpgacontrol.h similarity index 100% rename from fpgacontrol.h rename to zynq_7010_code/fpgacontrol.h diff --git a/hgkilltimer.sh b/zynq_7010_code/hgkilltimer.sh similarity index 100% rename from hgkilltimer.sh rename to zynq_7010_code/hgkilltimer.sh diff --git a/huagao_gpio.sh b/zynq_7010_code/huagao_gpio.sh similarity index 100% rename from huagao_gpio.sh rename to zynq_7010_code/huagao_gpio.sh diff --git a/imageipc.h b/zynq_7010_code/imageipc.h similarity index 100% rename from imageipc.h rename to zynq_7010_code/imageipc.h diff --git a/logs_out.cpp b/zynq_7010_code/logs_out.cpp similarity index 100% rename from logs_out.cpp rename to zynq_7010_code/logs_out.cpp diff --git a/logs_out.h b/zynq_7010_code/logs_out.h similarity index 100% rename from logs_out.h rename to zynq_7010_code/logs_out.h diff --git a/main.cpp b/zynq_7010_code/main.cpp similarity index 100% rename from main.cpp rename to zynq_7010_code/main.cpp diff --git a/scannersysinfo.h b/zynq_7010_code/scannersysinfo.h similarity index 100% rename from scannersysinfo.h rename to zynq_7010_code/scannersysinfo.h diff --git a/scanservices_utils.h b/zynq_7010_code/scanservices_utils.h similarity index 100% rename from scanservices_utils.h rename to zynq_7010_code/scanservices_utils.h diff --git a/serialib.cpp b/zynq_7010_code/serialib.cpp similarity index 100% rename from serialib.cpp rename to zynq_7010_code/serialib.cpp diff --git a/serialib.h b/zynq_7010_code/serialib.h similarity index 100% rename from serialib.h rename to zynq_7010_code/serialib.h diff --git a/zynq_7010_code/test.cpp b/zynq_7010_code/test.cpp index aa0b8c6..2d9c60a 100644 --- a/zynq_7010_code/test.cpp +++ b/zynq_7010_code/test.cpp @@ -1,101 +1,64 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include"JsonConfig.h" -#define erroe_status -1 -#define start_sleep 1 -#define close_sleep 0 - -int readfile(int fd, char* buf,int num ) -{ - lseek(fd, 0, SEEK_SET); - int ret = read(fd, buf, num); - if (ret == -1) - { - printf("readfile error:%s\r\n",strerror(ret)); - return erroe_status; - } - if (ret == 0) - { - printf("readfile error:%s\r\n","service connection is lost"); - return erroe_status; - } - printf("sleep processes len :%d\r\n",ret); - return atoi(buf); -} -void start_enter_lowpwoer(int time) -{ - int seconds = time; - - if(time < 0 || time < 180) - seconds = 180; - else - seconds = time; - - std::string str="sh /mnt/flash-disk/countdown.sh start 0 0 "+std::to_string(seconds) + " &"; - printf("start_enter_lowpwoer %s \n",str.c_str()); - - int ret = system(str.c_str()); -} -void stop_countdown() -{ - int ret = system("sh /mnt/flash-disk/killtimer.sh"); - printf("system stop_countdown :%d\r\n",ret); -} - -int main(int argc, char *argv[]) -{ - int fd = -1; - int ret = 0; - pollfd pfd; - ret = mkfifo("/home/root/dev/sleep", 0666); - if(ret != 0) - { - perror("/home/root/dev/sleep"); - } - - printf("before open\n"); - fd = open("/home/root/dev/sleep", O_RDONLY);//等着只写 - if(fd < 0) - { - perror("open fifo"); - } - - printf("after open\n"); - - char buffer[12]; - JsonConfig js; - - - while (true) - { - ret = readfile(fd,buffer,sizeof(buffer)); - printf("while read buf:[%d]\n", ret); - if (ret == -1) - { - system("sh /mnt/flash-disk/leds.sh 1"); - sleep(3); - continue; - } - - if (ret == 1) - { - ScannerScanInfo info = js.GetScanInfo(); - stop_countdown(); - sleep(3); - start_enter_lowpwoer(info.SleepTime); - } - else - stop_countdown(); - - } - close(fd); - return 0; -} - - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define VIDPID_PATH "/usr/local/bin/mtpd.sh" + +/* + * FunctionName: main + * Description: + */ +int main01(int argc, char *argv[]) +{ + int ret = 0; + printf("argc = %d \n", argc); + if (argc != 3) + { + return -1; + } + unsigned int i_vid = atoi(argv[1]); + unsigned int i_pid = atoi(argv[2]); + printf("arg0 = %d arg1=%d \n", i_vid, i_pid); + char buf_vid[5] ={0}; + char buf_pid[5] ={0}; + buf_vid[4]='\0'; + buf_pid[4]='\0'; + sprintf(buf_vid,"%04x",i_vid); + sprintf(buf_pid,"%04x",i_pid); + printf("buf_vid = %s buf_pid=%s \n", buf_vid, buf_pid); + if (i_pid > 0 && i_vid > 0) + { + FILE *fd; + + fd = fopen(VIDPID_PATH, "rb+"); + if (!fd) { + printf( "error open /usr/local/bin/mtp.sh...\n"); + return -1; + } + else { + printf( "open %s scuess.fd = %d\n", VIDPID_PATH,fd); + } + + /*set vid*/ + fseek(fd , 0x18e , SEEK_SET); + ret = fwrite(buf_vid, 1, 4, fd); + + /*set pid*/ + fseek(fd , 0x1c8 , SEEK_SET); + ret = fwrite(buf_pid, 1, 4, fd); + + fclose(fd); + return 0; + } + + return -1; +} /* ---------- end of function main ---------- */ diff --git a/threadex.h b/zynq_7010_code/threadex.h similarity index 100% rename from threadex.h rename to zynq_7010_code/threadex.h diff --git a/usb_gadget.h b/zynq_7010_code/usb_gadget.h similarity index 100% rename from usb_gadget.h rename to zynq_7010_code/usb_gadget.h diff --git a/usbdevice.cpp b/zynq_7010_code/usbdevice.cpp similarity index 100% rename from usbdevice.cpp rename to zynq_7010_code/usbdevice.cpp diff --git a/usbdevice.h b/zynq_7010_code/usbdevice.h similarity index 100% rename from usbdevice.h rename to zynq_7010_code/usbdevice.h diff --git a/usbstring.cpp b/zynq_7010_code/usbstring.cpp similarity index 100% rename from usbstring.cpp rename to zynq_7010_code/usbstring.cpp diff --git a/usbstring.h b/zynq_7010_code/usbstring.h similarity index 100% rename from usbstring.h rename to zynq_7010_code/usbstring.h diff --git a/utilsfunc.cpp b/zynq_7010_code/utilsfunc.cpp similarity index 100% rename from utilsfunc.cpp rename to zynq_7010_code/utilsfunc.cpp diff --git a/utilsfunc.h b/zynq_7010_code/utilsfunc.h similarity index 100% rename from utilsfunc.h rename to zynq_7010_code/utilsfunc.h