|
@@ -239,14 +239,34 @@ Error_manager Snap7_communication_base::read_data_buf(Snap7_buf& snap7_buf)
|
|
|
if ( snap7_buf.m_communication_mode != Snap7_buf::NO_COMMUNICATION)
|
|
|
{
|
|
|
std::unique_lock<std::mutex> lck(m_communication_lock);
|
|
|
- int result = m_snap7_client.AsDBRead(snap7_buf.m_id, snap7_buf.m_start_index, snap7_buf.m_size, snap7_buf.mp_buf_reverse);
|
|
|
+// int result = m_snap7_client.AsDBRead(snap7_buf.m_id, snap7_buf.m_start_index, snap7_buf.m_size, snap7_buf.mp_buf_reverse);
|
|
|
+
|
|
|
+ char t_buf[20] ;
|
|
|
+ memset(t_buf, 0, 20);
|
|
|
+ int result = m_snap7_client.AsDBRead(123, 10, 30, t_buf);
|
|
|
+ unsigned char ccccc = *((unsigned char*)t_buf);
|
|
|
+ std::cout << " huli test :::: " << " ccccc = " << (unsigned int)ccccc << std::endl;
|
|
|
+
|
|
|
+
|
|
|
+ std::cout << " huli test :::: " << " AsDBRead result = " << result << std::endl;
|
|
|
if ( snap7_buf.m_communication_mode == Snap7_buf::ONCE_COMMUNICATION )
|
|
|
{
|
|
|
snap7_buf.m_communication_mode = Snap7_buf::NO_COMMUNICATION;
|
|
|
}
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(m_communication_delay_time_ms));
|
|
|
if (result==0)
|
|
|
{
|
|
|
t_error = reverse_byte(snap7_buf.mp_buf_reverse, snap7_buf.mp_buf_obverse, snap7_buf.m_size);
|
|
|
+
|
|
|
+// unsigned int ccccc = *((unsigned int*)snap7_buf.mp_buf_reverse);
|
|
|
+//
|
|
|
+// std::cout << " huli test :::: " << " snap7_buf.m_id = " << snap7_buf.m_id << std::endl;
|
|
|
+// std::cout << " huli test :::: " << " snap7_buf.m_start_index = " << snap7_buf.m_start_index << std::endl;
|
|
|
+// std::cout << " huli test :::: " << " snap7_buf.m_size = " << snap7_buf.m_size << std::endl;
|
|
|
+// std::cout << " huli test :::: " << " ccccc = " << (unsigned int)ccccc << std::endl;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if ( t_error != Error_code::SUCCESS )
|
|
|
{
|
|
|
return t_error;
|
|
@@ -278,10 +298,12 @@ Error_manager Snap7_communication_base::write_data_buf(Snap7_buf& snap7_buf)
|
|
|
std::unique_lock<std::mutex> lck(m_communication_lock);
|
|
|
int result = m_snap7_client.AsDBWrite(snap7_buf.m_id, snap7_buf.m_start_index, snap7_buf.m_size,
|
|
|
snap7_buf.mp_buf_reverse);
|
|
|
+ std::cout << " huli test :::: " << " AsDBWrite result = " << result << std::endl;
|
|
|
if ( snap7_buf.m_communication_mode != Snap7_buf::ONCE_COMMUNICATION )
|
|
|
{
|
|
|
snap7_buf.m_communication_mode = Snap7_buf::NO_COMMUNICATION;
|
|
|
}
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(m_communication_delay_time_ms));
|
|
|
if (result == 0)
|
|
|
{
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(m_communication_delay_time_ms));
|
|
@@ -306,9 +328,13 @@ Error_manager Snap7_communication_base::reverse_byte(void* p_buf_in, void* p_buf
|
|
|
}
|
|
|
char* tp_in=(char*)p_buf_in;
|
|
|
char* tp_out=(char*)p_buf_out;
|
|
|
+// for(int i=0;i<size;++i)
|
|
|
+// {
|
|
|
+// tp_out[i]=tp_in[size-i-1];
|
|
|
+// }
|
|
|
for(int i=0;i<size;++i)
|
|
|
{
|
|
|
- tp_out[i]=tp_in[size-i-1];
|
|
|
+ tp_out[i]=tp_in[i];
|
|
|
}
|
|
|
return Error_code::SUCCESS;
|
|
|
}
|