The function is used to set the device data (for example, the time segment, user information, and holiday information). The device data can be one or multiple records.
[in]: The handle that is returned when the connection is successful.
[in]: Data table name. Attached table 4 lists the available data tables.
[in]: Data record; the data is expressed in a text format; the multiple records are separated by \r\n, and the “Field=Value” pairs are separated by \t.
[in]: The default value is null; it is used for extension.
When the returned value is 0, it indicates that the operation is successful. When the returned value is a negative value, it indicates that the operation fails. Attached table 5 lists the information about the error codes.
table = "user" # User information table data = "Pin=19999\tCardNo=13375401\tPassword=1\r\nPin=2\tCardNo=14128058\tPassword=1" p_table = create_string_buffer(table) str_buf = create_string_buffer(data) ret = self.commpro.SetDeviceData(self.hcommpro, p_table, str_buf, ‘’) # Upload the str_buf data to the user information table
int ret = 0; string devtablename = "user"; string data = "Pin=19999\tCardNo=13375401\tPassword=1\r\nPin=2\tCardNo=14128058\tPassword=1"; string options = ""; ret = SetDeviceData(h, devtablename, data, options);
[DllImport("plcommpro.dll", EntryPoint = "SetDeviceData")] public static extern int SetDeviceData(IntPtr h, string tablename, string data, string options); private void SetDeviceData_Pull(string data = "CardNo\tPin\tPassword\tGroup\tStartTime\tEndTime", string options = "", string devtablename = "holiday") { int ret = 0; if (IntPtr.Zero != h) { ret = SetDeviceData(h, devtablename, data, options); if (ret >= 0) { MessageBox.Show("SetDeviceData operation succeed!"); } else MessageBox.Show("SetDeviceData operation failed!"); } else { MessageBox.Show("Connect device failed!"); } }