Skip to content

Commit

Permalink
Merge pull request #125 in OS/onboard-sdk from mop_sample_refactoring…
Browse files Browse the repository at this point in the history
… to develop

* commit 'd3483ecaa8378c7188ec5bad6030f0df96eec174':
  feat:MOP sample refactoring
  fix:fix QA test log and writefile issue
  • Loading branch information
charles.huang committed Apr 23, 2020
2 parents 9185c7f + d3483ec commit 422c9db
Show file tree
Hide file tree
Showing 7 changed files with 704 additions and 473 deletions.
10 changes: 6 additions & 4 deletions sample/platform/linux/mop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ project(mop-sample)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -g -O0")

include_directories(./)

FILE(GLOB SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/../common/dji_linux_environment.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../common/dji_linux_helpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../hal/*.c
${CMAKE_CURRENT_SOURCE_DIR}/../osal/*.c
)

add_executable(mop_client_sample ${SOURCE_FILES} mop_client_main.cpp)
add_executable(mop_QA_test ${SOURCE_FILES} mop_QA_test.cpp)

add_executable(mop_server_sample ${SOURCE_FILES} mop_server_main.cpp)
add_executable(op_download_sample ${SOURCE_FILES} op_download_sample.cpp)

add_executable(mop_QA_test ${SOURCE_FILES} mop_QA_test.cpp)
add_executable(op_upload_sample ${SOURCE_FILES} op_upload_sample.cpp)

target_link_libraries(mop_client_sample crypto)
target_link_libraries(op_download_sample crypto)
36 changes: 18 additions & 18 deletions sample/platform/linux/mop/mop_QA_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ static void* PipelineRecvTask(void *arg)

handle = (MopPipeline *)arg;
if(handle == NULL) {
DERROR("recv task param check failed!\n");
DERROR("[PipelineID-%d]recv task param check failed!\n", handle->getId());
return NULL;
}

recvBuf = malloc(READ_ONCE_BUFFER_SIZE);
if (recvBuf == NULL) {
DERROR("malloc recv buffer error\n");
DERROR("[PipelineID-%d]malloc recv buffer error\n", handle->getId());
return NULL;
}

Expand All @@ -133,17 +133,17 @@ static void* PipelineRecvTask(void *arg)
MopPipeline::DataPackType readPacket = {(uint8_t *)recvBuf, READ_ONCE_BUFFER_SIZE};
mopRet = handle->recvData(readPacket, &readPacket.length);
if (mopRet != MOP_PASSED) {
DERROR("recv whole file data failed!, realLen = %d\n", readPacket.length);
DERROR("[PipelineID-%d]recv whole file data failed!, realLen = %d\n", handle->getId(), readPacket.length);
//break;
} else {
DSTATUS("recv whole file data success!, realLen = %d\n", readPacket.length);
DSTATUS("[PipelineID-%d]recv whole file data success!, realLen = %d\n", handle->getId(), readPacket.length);
writeStreamData(logFileName, readPacket.data, readPacket.length);
cnt++;
DSTATUS("[PipelineID-%d]recv cnt %d!\n", handle->getId(), cnt);
}
writeStreamData(logFileName, readPacket.data, readPacket.length);
cnt++;
DSTATUS("recv cnt %d!\n", cnt);
if (recvExitMsg) break;
}
DSTATUS("mop channel recv task end!\n");
DSTATUS("[PipelineID-%d]mop channel recv task end!\n", handle->getId());

if(recvBuf != NULL)
free(recvBuf);
Expand All @@ -159,7 +159,7 @@ static void* PipelineSendTask(void *arg)

handle = (MopPipeline *)arg;
if(handle == NULL) {
DERROR("send task param check failed!\n");
DERROR("[PipelineID-%d]send task param check failed!\n");
return NULL;
}

Expand All @@ -174,38 +174,38 @@ static void* PipelineSendTask(void *arg)
auto targetFileSize = get_file_size(TEST_SEND_FILE_NAME);
FILE *fp = fopen(TEST_SEND_FILE_NAME, "r");
if (fp == NULL) {
DERROR("open %s error\n ", TEST_SEND_FILE_NAME);
DERROR("[PipelineID-%d]open %s error\n ", handle->getId(), TEST_SEND_FILE_NAME);
return NULL;
}
DSTATUS("targetFileSize = %d", targetFileSize);
DSTATUS("[PipelineID-%d]targetFileSize = %d", handle->getId(), targetFileSize);
addr = malloc(SEND_ONCE_BUFFER_SIZE);

int totalSize = 0;
do {
int ret = fread((uint8_t *) addr, 1, SEND_ONCE_BUFFER_SIZE, fp);
totalSize += ret;
DSTATUS("total read size : %d\n", totalSize);
DSTATUS("----------- pdf read bytes ret = %d\n", ret);
DSTATUS("[PipelineID-%d]total read size : %d\n", handle->getId(), totalSize);
DSTATUS("[PipelineID-%d]----------- pdf read bytes ret = %d\n", handle->getId(), ret);

MopPipeline::DataPackType writePacket = {(uint8_t *) addr, (uint32_t) ret};

DSTATUS("Do sendData to PSDK, size : %d\n", writePacket.length);
DSTATUS("[PipelineID-%d]Do sendData to PSDK, size : %d\n", handle->getId(), writePacket.length);
mopRet = handle->sendData(writePacket, &writePacket.length);
if (mopRet != MOP_PASSED) {
DERROR("mop send error,stat:%lld, writePacket.length = %d\n", mopRet,
DERROR("[PipelineID-%d]mop send error,stat:%lld, writePacket.length = %d\n", handle->getId(), mopRet,
writePacket.length);
break;
} else {
DERROR("mop send success,stat:%lld, writePacket.length = %d\n", mopRet,
DERROR("[PipelineID-%d]mop send success,stat:%lld, writePacket.length = %d\n", handle->getId(), mopRet,
writePacket.length);
}
cnt++;
DSTATUS("send cnt %d!\n", cnt);
DSTATUS("[PipelineID-%d]send cnt %d!\n", handle->getId(), cnt);

if (recvExitMsg) break;
} while (totalSize < targetFileSize);

DSTATUS("mop channel send task end!\n");
DSTATUS("[PipelineID-%d]mop channel send task end!\n", handle->getId());
free(addr);
fclose(fp);

Expand Down
242 changes: 0 additions & 242 deletions sample/platform/linux/mop/mop_client_main.cpp

This file was deleted.

Loading

0 comments on commit 422c9db

Please sign in to comment.