modbus/mb_runtime.c
changeset 2011 64268e87613e
parent 1913 338e2f51b685
child 2019 92f02bb17c7e
equal deleted inserted replaced
2010:bb9c28bd204f 2011:64268e87613e
   490 	int index;
   490 	int index;
   491 
   491 
   492 	for (index=0; index < NUMBER_OF_CLIENT_REQTS; index ++){
   492 	for (index=0; index < NUMBER_OF_CLIENT_REQTS; index ++){
   493 		/*just do the output requests */
   493 		/*just do the output requests */
   494 		if (client_requests[index].req_type == req_output){
   494 		if (client_requests[index].req_type == req_output){
   495 			pthread_mutex_lock(&(client_requests[index].coms_buf_mutex));
   495 			if(pthread_mutex_trylock(&(client_requests[index].coms_buf_mutex)) == 0){
   496 			// copy from plcv_buffer to coms_buffer
   496                 // copy from plcv_buffer to coms_buffer
   497 			memcpy((void *)client_requests[index].coms_buffer /* destination */,
   497                 memcpy((void *)client_requests[index].coms_buffer /* destination */,
   498 			       (void *)client_requests[index].plcv_buffer /* source */,
   498                        (void *)client_requests[index].plcv_buffer /* source */,
   499 			       REQ_BUF_SIZE * sizeof(u16) /* size in bytes */);
   499                        REQ_BUF_SIZE * sizeof(u16) /* size in bytes */);
   500 			pthread_mutex_unlock(&(client_requests[index].coms_buf_mutex));
   500                 pthread_mutex_unlock(&(client_requests[index].coms_buf_mutex));
       
   501             }
   501 		}
   502 		}
   502 	}
   503 	}
   503 }
   504 }
   504 
   505 
   505 
   506 
   510 	int index;
   511 	int index;
   511 
   512 
   512 	for (index=0; index < NUMBER_OF_CLIENT_REQTS; index ++){
   513 	for (index=0; index < NUMBER_OF_CLIENT_REQTS; index ++){
   513 		/*just do the input requests */
   514 		/*just do the input requests */
   514 		if (client_requests[index].req_type == req_input){
   515 		if (client_requests[index].req_type == req_input){
   515 			pthread_mutex_lock(&(client_requests[index].coms_buf_mutex));
   516 			if(pthread_mutex_trylock(&(client_requests[index].coms_buf_mutex)) == 0){
   516 			// copy from coms_buffer to plcv_buffer
   517                 // copy from coms_buffer to plcv_buffer
   517 			memcpy((void *)client_requests[index].plcv_buffer /* destination */,
   518                 memcpy((void *)client_requests[index].plcv_buffer /* destination */,
   518 			       (void *)client_requests[index].coms_buffer /* source */,
   519                        (void *)client_requests[index].coms_buffer /* source */,
   519 			       REQ_BUF_SIZE * sizeof(u16) /* size in bytes */);
   520                        REQ_BUF_SIZE * sizeof(u16) /* size in bytes */);
   520 			pthread_mutex_unlock(&(client_requests[index].coms_buf_mutex));
   521                 pthread_mutex_unlock(&(client_requests[index].coms_buf_mutex));
       
   522             }
   521 		}
   523 		}
   522 	}
   524 	}
   523 }
   525 }
   524 
   526 
   525 
   527