IMDTouchKnowledge BaseShop main store

Troubleshooting

Weintek Free Protocol INPORT receive length and macro debug

HMI and touchscreens Published 5 min read By IMDTouch engineering team

Short answer

In EasyBuilder Pro Free Protocol Ethernet macros, INPORT takes the maximum receive buffer length in its third argument and writes the received byte count into its fourth argument. Passing zero as the third argument caps every read at zero bytes, so guard conditions on that variable never see incoming data and unguarded SetData calls overwrite HMI registers with empty buffers. Set the third argument to the buffer size, check the fourth argument before calling SetData, and verify runtime values with TRACE in EasyDiagnoser.

A workstation monitor showing a script in a code editor with a syntax check result, linked by a cable to the operator panel the script runs on
On this page
  1. Why INPORT returns zero and overwrites LW registers
  2. Corrected Free Protocol INPORT macro structure
  3. Sizing the INPORT buffer and guard for a 20-byte TCP frame
  4. Debugging macro execution with TRACE and EasyDiagnoser
  5. Step-by-step verification and project download checklist
  6. Questions asked

When an EasyBuilder Pro Free Protocol Ethernet macro calls INPORT with zero in the third argument, the HMI caps every read at zero bytes and ignores incoming TCP packets. The third argument defines the maximum byte count to read, while the fourth argument returns the actual number of bytes received. Fix the macro by passing the buffer size in the third argument, checking the fourth argument before calling SetData, and confirming live values with TRACE in EasyDiagnoser.

Why INPORT returns zero and overwrites LW registers #

Two separate faults occur when the third and fourth arguments of INPORT are swapped. First, initializing the third argument to 0 and treating it as the returned byte count tells the HMI to read at most zero bytes from "Free Protocol Server (Ethernet)". Even when an external TCP client transmits a valid message, the read length stays 0 and any condition testing that variable never executes.

Second, passing a constant such as 1 in the fourth argument as if it were a wait time breaks the receive guard. Because INPORT overwrites that fourth variable with the number of bytes actually read, any periodic macro that calls SetData without checking the fourth argument copies an empty buffer into "Local HMI" LW registers on idle scans, erasing the last valid payload.

Software build differences can also affect Free Protocol handling. The EasyBuilder Pro V6.09.01.671 release notes specifically record a Free Protocol update under item 12 alongside protocol driver changes, so confirm the installed build before assuming a hardware or network fault. When a project combines Free Protocol with standard PLC drivers, also check how many protocol drivers one HMI project can run to keep communication loads within panel limits.

Corrected Free Protocol INPORT macro structure #

The example below uses the documented EasyBuilder Pro macro identifiers macro_command main(), end macro_command, INPORT, SetData, TRACE, FILL, "Free Protocol Server (Ethernet)", "Local HMI", and LW. The local variables Response, RLength, and CRecvd are illustrative names declared with explicit types and initial values.

macro_command main()
char Response[20] = ""
short RLength = 20
short CRecvd = 0

INPORT(Response[0], "Free Protocol Server (Ethernet)", RLength, CRecvd)
if CRecvd >= 4 then
    TRACE("CRecvd = %d", CRecvd)
    SetData(Response[0], "Local HMI", LW, 0, 20)
end if
end macro_command

In this structure, RLength stays fixed at the buffer capacity so INPORT can read incoming bytes up to that limit, while CRecvd receives the actual byte count returned by the Ethernet port. SetData executes only when CRecvd reaches the minimum payload length. If incoming messages vary in length and trailing characters must be cleared, uncomment or add FILL(Response[0], 0, RLength) before INPORT. Similar strict argument-order behavior applies to Weintek macro recipe lookup functions.

Sizing the INPORT buffer and guard for a 20-byte TCP frame #

Inputs for this case come from a typical Free Protocol Ethernet receive macro configuration:

  • Illustrative receive array capacity: 20 bytes (char Response[20]).
  • Illustrative minimum valid payload threshold: 4 bytes.
  • Illustrative timed macro execution interval: 5 seconds.
  • Illustrative test traffic: a 12-byte TCP frame on an active scan, followed by 0 bytes on the next idle scan.

The rule is direct: set the third INPORT argument equal to the buffer capacity in bytes, capture the actual read count in the fourth argument, and allow SetData to write LW registers only when the fourth argument is at least the minimum valid payload length.

For the active scan, RLength is 20 bytes and the external client sends 12 bytes, so INPORT writes 12 into CRecvd. Testing the guard gives 12 >= 4, which is true, so SetData copies the 20-byte buffer into LW 0. On the next 5-second scan with no incoming TCP traffic, INPORT writes 0 into CRecvd. Testing the guard gives 0 >= 4, which is false, so the macro skips SetData.

The result is that the 12-byte payload latches cleanly into LW 0 and stays visible across subsequent 5-second idle cycles instead of disappearing. The decision is fixed by that threshold: keep the third argument at 20 bytes and block SetData whenever CRecvd is below 4 bytes. If the external device sends frames longer than the current buffer capacity, raise both the array declaration and RLength to match the longest expected packet before deployment.

Debugging macro execution with TRACE and EasyDiagnoser #

Verify the corrected macro in EasyDiagnoser using TRACE output rather than guessing from HMI screen tags. Place one TRACE statement immediately after INPORT to log CRecvd on every cycle, and keep a second TRACE inside the if block to confirm when SetData runs.

Prove the fix with two bench tests:

  • Run the timed macro with no TCP client transmitting and confirm EasyDiagnoser prints CRecvd = 0 without triggering the SetData trace line, while existing LW 0 values remain unchanged.
  • Transmit a 4-byte or longer TCP payload from the client and confirm EasyDiagnoser prints the exact received byte count and LW 0 updates with the new data.

Step-by-step verification and project download checklist #

  • Verify the device string in INPORT matches "Free Protocol Server (Ethernet)" in the EasyBuilder Pro system parameters.
  • Set the third INPORT argument to the buffer array length and initialize the fourth argument to 0 before each read.
  • Gate SetData on the fourth argument so idle scans never overwrite LW registers with empty arrays.
  • Call FILL before INPORT when variable-length messages must clear leftover trailing bytes from earlier frames.
  • Download the updated project to an MT8071iP over Ethernet > IP tab using the F7 shortcut documented in the MT6071iP and MT8071iP Series Installation and Startup Guide, and verify stable 24±20% Volts DC panel power if Ethernet links drop during testing.
  • Check the EasyBuilder Pro build against the EasyBuilder Pro V6.09.01.671 release notes if Free Protocol behavior differs between simulation and the physical HMI.

Questions asked

Does INPORT wait for data when no TCP packet is in the Ethernet buffer?

No. The fourth argument in INPORT is an output variable that returns how many bytes were read, not a timeout delay. If no TCP data is waiting when the macro runs, INPORT returns immediately with zero in the fourth argument. Control how often the HMI checks for incoming Ethernet frames by adjusting the macro's timed execution interval or triggering the macro from a bit change.

Why do old characters remain at the end of LW registers after a shorter TCP message arrives?

When a shorter message arrives, INPORT only writes the newly received characters into the start of the buffer array. If you copy the full array to LW registers without clearing it first, trailing bytes from a longer previous message stay behind in memory. Call FILL with zero across the buffer array before INPORT whenever incoming TCP frame lengths vary.

Can you step through a Weintek EasyBuilder Pro macro line by line like a PLC debugger?

EasyBuilder Pro does not provide a breakpoint-based step debugger for HMI macros. Instead, insert TRACE calls at key points in the macro and watch the printed variable values in EasyDiagnoser during online simulation or while connected to the panel over Ethernet. Printing both the returned byte count and the branch taken isolates argument and guard errors quickly.

Keep reading

  • Explainer

    How many protocols one HMI project can run

    One HMI project holds up to 64 configured devices, and the protocols it can run are the distinct device drivers those endpoints need. Three drivers are series-restricted: CAN Bus is absent on standard cMT2000x panels, EtherNet/IP Server runs only on cMT panels, and BACnet/MSTP Server runs on cMT and cMT-X panels. List endpoints, group them by driver, then confirm each driver against the panel series.

    HMI and touchscreens

  • Explainer

    Can a Weintek HMI Command Siemens CPU Run and Stop

    A Weintek panel can command a Siemens CPU between run and stop only when the EasyBuilder Pro driver for that CPU family documents an operating-state operation; Siemens documents that GET/PUT data access works in either state, so working tags prove nothing. If the operation is absent from your driver, mode changes stay on TIA Portal, a Siemens operator panel or the S7-1200's built-in web server, which offers stop and run and no restart command.

    HMI and touchscreens

  • Troubleshooting

    Why an EasyBuilder Pro simulator fails to connect to a LOGO! OBA8

    The online simulator connects to a physical LOGO! OBA8 only after the LOGO! network project's display connection is set as a server with an operator panel selected, and EasyBuilder Pro is set to OBA8, not LOGO 7. Point the driver at the LOGO!'s static IP address and run the simulation over Ethernet.

    HMI and touchscreens

Adding a line break inside a Weintek EasyBuilder label entry