+function get_parameter(record)
+ return tonumber(get_file_content(record["path"])) * record["scale"] + record["correction"]
+end
+
+function string.fromhex(str)
+ return (str:gsub('..', function (cc)
+ return string.char(tonumber(cc, 16))
+ end))
+end
+
+function string.tohex(str)
+ return (str:gsub('.', function (c)
+ return string.format('%02X', string.byte(c))
+ end))
+end
+
+function get_mhz(record)
+ local p = record["rs232"]
+ p:write(string.fromhex("ff0186000000000079"))
+ local e, s = p:read(9,1000)
+ return s:byte(3)*256+s:byte(4)
+end
+
+function init_serial_device(device,subsystem,parameters)
+
+ rs232 = require("luars232")
+
+ pcall(function ()
+
+ local e, port = rs232.open(device["port"])
+
+ if subsystem == "mhz" then
+
+ assert(port:set_baud_rate(rs232.RS232_BAUD_9600) == rs232.RS232_ERR_NOERROR)
+ assert(port:set_data_bits(rs232.RS232_DATA_8) == rs232.RS232_ERR_NOERROR)
+ assert(port:set_parity(rs232.RS232_PARITY_NONE) == rs232.RS232_ERR_NOERROR)
+ assert(port:set_stop_bits(rs232.RS232_STOP_1) == rs232.RS232_ERR_NOERROR)
+ assert(port:set_flow_control(rs232.RS232_FLOW_OFF) == rs232.RS232_ERR_NOERROR)
+
+ getparameter = {}
+
+ getparameter["rs232"] = port
+ getparameter["function"] = get_mhz
+ getparameter["name"] = "CO2_PPM"
+ getparameter["sensor"] = "MHZ19"
+ parameters[#parameters+1] = getparameter
+
+ end
+
+ end)
+
+end
+
+function init_i2c_device(device,subsystem,parameters)