User Tools

Site Tools


en-us_commands:reference:imodbusrtumasterinit

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en-us_commands:reference:imodbusrtumasterinit [2026/09/07 21:52] – 만듦 - 바깥 편집 127.0.0.1en-us_commands:reference:imodbusrtumasterinit [2026/09/08 00:53] (current) – 바깥 편집 127.0.0.1
Line 17: Line 17:
  
 <code cpp> <code cpp>
-ImodbusRTUmasterInit(Serial2, 9600, SERIAL_8N1);+uint16_t data[10]; 
 +uint16_t readValue0; 
 +uint16_t readValue1; 
 + 
 +void setup() { 
 +  ImodbusRTUmasterInit(Serial2, 9600);  // Set the Master's communication port and baud rate. 
 +
 + 
 +void loop() { 
 +  uint8_t result; 
 + 
 +  result = ImodbusRTUmaster(Serial2, 1, 0x03, 0, 2, data);  // Execute a single Master request immediately. 
 +  if (result == IMODBUS_RTU_SUCCESS) { 
 +    readValue0 = data[0]; 
 +    readValue1 = data[1]; 
 +  } 
 + 
 +  data[0] = 1234; 
 +  ImodbusRTUmaster(Serial2, 1, 0x06, 10, 1data);  // Execute a single Master request immediately. 
 +}
 </code> </code>
  
Line 27: Line 46:
   * When sharing ''M'' and ''D'' with Cnet/MC Protocol, define a single final size and initialization order. Do not call ''ImodbusRTUMem()'' or ''ICnetMem()'' again at runtime.   * When sharing ''M'' and ''D'' with Cnet/MC Protocol, define a single final size and initialization order. Do not call ''ImodbusRTUMem()'' or ''ICnetMem()'' again at runtime.
   * Memory allocation functions do not return success status. For nonzero sizes, verify that ''M'' and ''D'' are not ''nullptr'' before accessing them in user code.   * Memory allocation functions do not return success status. For nonzero sizes, verify that ''M'' and ''D'' are not ''nullptr'' before accessing them in user code.
 +
 +===== Built-in Commands in the Same Category =====
 +
 +  * [[:en-us_commands:reference:imodbusrtumaster|ImodbusRTUmaster() View detailed description]]
 +  * [[:en-us_commands:reference:imodbusrtumasteradd|ImodbusRTUmasterAdd() View detailed description]]
 +  * [[:en-us_commands:reference:imodbusrtumasterrun|ImodbusRTUmasterRun() View detailed description]]
  
 [[:en-us_commands:builtin|← Built-in Command List]] [[:en-us_commands:builtin|← Built-in Command List]]
  
en-us_commands/reference/imodbusrtumasterinit.1788785567.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki