|
@@ -205,17 +205,16 @@ int main(int argc,char* argv[])
|
|
|
buf.m_size=sizeof(plc_data);
|
|
|
buf.m_start_index=setting_parameter.plc_setting().start_id();
|
|
|
buf.mp_buf_reverse=&plc_data;
|
|
|
- /*int result = m_snap7_client.AsDBWrite(snap7_buf.m_id, snap7_buf.m_start_index, snap7_buf.m_size,
|
|
|
- snap7_buf.mp_buf_reverse);*/
|
|
|
|
|
|
- //code=snap7_client.read_data_buf(buf);
|
|
|
code=snap7_client.write_data_buf(buf);
|
|
|
- /*unsigned short a;
|
|
|
- memcpy(&a,buf.mp_buf_reverse,2);
|
|
|
- printf("------------%d\n",bswap_16(a));*/
|
|
|
+
|
|
|
|
|
|
if(code!=SUCCESS)
|
|
|
{
|
|
|
+ snap7_client.communication_uninit();
|
|
|
+ usleep(500*1000);
|
|
|
+ snap7_client.communication_init(setting_parameter.plc_setting().ip());
|
|
|
+ usleep(500*1000);
|
|
|
std::cout<<code<<std::endl;
|
|
|
}
|
|
|
|