<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Send Data to a specified Register with TCP/IP Cleint Server</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/7a9c941b30/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/7a9c941b30/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/7a9c941b30/</id><updated>2021-08-25T20:39:48.684000Z</updated><subtitle>Recent posts to Send Data to a specified Register with TCP/IP Cleint Server</subtitle><entry><title>Send Data to a specified Register with TCP/IP Cleint Server</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/7a9c941b30/?limit=25#3b6c" rel="alternate"/><published>2021-08-25T20:39:48.684000Z</published><updated>2021-08-25T20:39:48.684000Z</updated><author><name>navidsa198</name><uri>https://forge.codesys.com/u/navidsa198/</uri></author><id>https://forge.codesys.comfc010518afe53465648d842d5423769ffdb053e0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Helo everyone&lt;br/&gt;
I could make a TCP/Ip Client Server conection according this page:&lt;br/&gt;
&lt;a href="https://faq.codesys.com/display/CDSFAQ/TCP%3A+Example+for+Server+and+Client" rel="nofollow"&gt;https://faq.codesys.com/display/CDSFAQ/TCP%3A+Example+for+Server+and+Client&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now I have a Server and I want to send data to this Server.&lt;br/&gt;
in the data sheet it is written I sould send data to a specified register:&lt;/p&gt;
&lt;p&gt;Register 1000 for speed control. Register 1200 for direction&lt;/p&gt;
&lt;p&gt;// Data uses little-endian format &lt;br/&gt;
// Commands are read or write to any of shared memory. &lt;br/&gt;
// The shared memory are defined in TGM.h as follows: &lt;br/&gt;
// enum class shared_memory : uint32_t&lt;br/&gt;
{ &lt;br/&gt;
// SYSTEM = 0, //!&amp;lt; TGM_SYSTEM &lt;br/&gt;
// DATA = 1, //!&amp;lt; TGM_DATA &lt;br/&gt;
// CAM = 2, //!&amp;lt; TGM_Cam_Profile &lt;br/&gt;
//OSC = 3, //!&amp;lt; TGM_Oscilloscope &lt;br/&gt;
// SERVO = 4, //!&amp;lt; TGM_Servo &lt;br/&gt;
// DIO = 5, //!&amp;lt; TGM_DIO &lt;br/&gt;
// INTERP = 6, //!&amp;lt; TGM_Interpolator &lt;br/&gt;
// INTERP_W = 7, //!&amp;lt; InterpolatorWriteMemory &lt;br/&gt;
// INTERP_R = 8, //!&amp;lt; InterpolatorReadMemory &lt;br/&gt;
 }; &lt;/p&gt;
&lt;p&gt;// The server only checks the offset and length against the size of the shared memory. The communication consists of TCP stream. The stream is bi-directional. There is always a command (see struct _tcp_cmd_header below), which can be followed by data (depending of command type and direction of the stream) // // Description is given in the client point of view.&lt;/p&gt;
&lt;p&gt;// Simple write: //  Client wants to write data to shared memory and does not wait for acknowledge. &lt;/p&gt;
&lt;p&gt;// Client sends a command followed by data. &lt;br/&gt;
// command.memory = 1; &amp;lt;wanted memory="" number,="" usually="" the="" data=""&amp;gt; &lt;br/&gt;
// command.setBit = 0; &lt;br/&gt;
// command.clrBit = 0; &lt;br/&gt;
// command.ack = 0; &lt;br/&gt;
// command.readOrWrite = TCP_CMD_WRITE (1); &lt;br/&gt;
// command.len = ... &amp;lt;length of="" the="" followed="" data="" in="" bytes=""&amp;gt;. The maximum len is 1500 bytes. Larger value can lead to undefined behavior. &lt;br/&gt;
// command.isAnsiString = 0; &lt;br/&gt;
// command.isWideString = 0; &lt;br/&gt;
// command.offset = .... &amp;lt;offset to="" the="" shared="" memory,="" user="" specific="" for="" data="" memory=""&amp;gt; // // The server just silently performs the command (no response). // // &amp;lt;/offset&amp;gt;&amp;lt;/length&amp;gt;&amp;lt;/wanted&amp;gt;&lt;/p&gt;
&lt;p&gt;Write with ack: //  Client wants to be sure the command arrived correctly // ... the same as above, only &lt;br/&gt;
// command.ack = 1; // // The server responds with the command only (with the same values), only len is set to zero &lt;br/&gt;
// command.len = 0;&lt;br/&gt;
// Write with set/clear any bit: // ----------------------------- // To make it easy to just set or clear a bit(s) in the shared memory, the logical operations can be performed. &lt;br/&gt;
// Client send the command followed by data (value). &lt;br/&gt;
// SetBit (i.e. destination |= value) &lt;br/&gt;
// command.setBit = 1; &lt;br/&gt;
// command.clrBit = 0; &lt;br/&gt;
// ClrBit (i.e. destination &amp;amp;= ~value) &lt;br/&gt;
// command.setBit = 0; &lt;br/&gt;
// command.clrBit = 1; &lt;br/&gt;
// ToggleBit (i.e. destination ^= value) &lt;br/&gt;
// command.setBit = 1; &lt;br/&gt;
// command.clrBit = 1; &lt;br/&gt;
// Note: the length must be multiple of 4 bytes, other values make undefined behavior. &lt;br/&gt;
// The write can be acknowledged, if necessary (see above).&lt;/p&gt;
&lt;p&gt;Can anybody please help me?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>