VisualHMI secure login: Hierarchical authorization and set_pwd password management

freeFree Technical Resource

This content is free to read, suitable for basic learning and search traffic.

Secure Login: Assign hierarchical authorization to interface controls, allowing users of different levels to view/operate different content. Supports levels 1-8 (0 for guests), with password configurable, editable via Lua, and automatic logout upon timeout.

1. Configure

Project → Project Settings → Security Level: Set the number of levels, passwords for each level, keep logged in, timeout for logout (in seconds), return to screen, keyboard position (default/centered), and user name.

VisualHMI secure login: Hierarchical authorization and set_pwd password management插图

2. Timeout Logout

When switching screens with the function button, check "User Level → Minimum Required Level", and if the level is insufficient, prompt for password via keyboard. Automatically log out upon idle timeout (only effective when "Keep Logged In" is enabled).

VisualHMI secure login: Hierarchical authorization and set_pwd password management插图1

3. Password Modification (LUA)

set_pwd(level, pwd, len): level 0-7 corresponds to password levels 1-8, pwd is a numeric password, len is optional (padded with leading zeros, e.g., if len=5, then 123 is stored as 00123).

Password is not supported for reading, and is mirrored to the RW area during initialization/modification:

function on_init()
  local _val = get_uint16(VT_RW, 0x2000)
  if _val ~= 0x0055 then
    set_uint32(VT_RW, 0x0000, 111111)
    set_uint32(VT_RW, 0x0002, 222222)
    set_uint32(VT_RW, 0x0004, 333333)
    set_uint32(VT_RW, 0x0006, 444444)
    set_uint32(VT_RW, 0x0008, 555555)
    set_pwd(0, 111111, 6); set_pwd(1, 222222, 6)
    set_pwd(2, 333333, 6); set_pwd(3, 444444, 6)
    set_pwd(4, 555555, 6)
    set_uint16(VT_RW, 0x2000, 0x0055)
    flash_sync()
  else
    set_pwd(0, get_uint32(VT_RW, 0x0000), 6)
    set_pwd(1, get_uint32(VT_RW, 0x0002), 6)
    -- ... 其余等级
  end
end

VisualHMI secure login: Hierarchical authorization and set_pwd password management插图2

The secure login password is the same as the installment passwordWrite-only, not read-only, and must be mirrored to the RW area by yourself. Leading zeros are a pitfall: if leading zeros are used (len=6, then 66 is stored as 000066),all level passwords must be uniformly padded with leading zerosOtherwise, it won't match. After making changes, save the flash_sync() function.

This is compiled from the VisualHMI development documentation of Guangzhou Dacai Technology (hmi-doc.gz-dc.com) and other technical tutorials titled "Secure Login". The copyright belongs to Dacai Technology.

Put this resource to use in a real project?

Go to the Tool Center for message parsing, CRC verification and device debugging, or submit your requirements for selection and integration advice.

Engineer Membership

Turn this article into actionable debugging resources

After activation, you can use advanced message parsing, resource pack downloads, code examples, engineering cases and priority technical support, suitable for real project delivery.

Unlimited Advanced Tools
Resource & Code Packs
Complete Engineering Case Library
Priority Technical Support

Leave a Reply

Your email address will not be published. Required fields are marked *.