Przejdź do głównej zawartości

Debug programs on an MC252

Ta treść nie jest jeszcze dostępna w Twoim języku.

An MC252 writes its system log on its memory card. Programs add to it with SYSLOG, and the device adds a line for each error that no handler of a program caught. HMI reads this log from the device when you look at it; it does not keep a copy.

The device logs program messages and errors only with device-side logging on.

  1. Open Setup → Endpoints, open the MC252, and select the Programs tab.
  2. Select Settings, turn on Device-side logging, and select Save.
  3. The next deploy saves the logging settings on the device. They apply after the device restarts; until then, the Device log says so.

See Change the device’s program settings.

Device log is under the programs on the Programs tab. It reads the latest entries from the device when the tab opens, and shows them newest first with the time in your time zone.

  • Refresh reads what the device logged since; only new bytes are read. If the log on the device was cleared or replaced, or grew by more than 32 KB since, the Device log starts over from its latest entries and says so.
  • Load earlier entries, at the end of the list, reads further back.
  • Errors, Messages and System choose the entries shown. System entries are the firmware’s own messages and are hidden at first. Device starts always show as a divider.
  • The search box keeps the entries that contain its text.

The device writes its log in batches, so a message can take up to about 15 seconds to appear. Nothing is read in the background: select Refresh to see new entries.

An unhandled error shows the error and the program line it happened on. The device does not log which program failed, so HMI works it out:

  • With one program on the device, the error links to that program’s line.
  • With several, it links to the programs whose task last failed with the same error. Line N in FILE.TXT opens the program at that line.
  • When no program matches, for example because a later run of the program succeeded, the entry shows only the line number. So does an error from before the device last loaded its programs: it may come from a program the device no longer runs.

A program can catch its own errors with an onerror label or TRYCALL, and log them with SYSLOG; see error codes and onerror.

edgeProgram.readDeviceLog returns the same entries, oldest first, for the API and the assistant. See Device log.