4 #IFDEF NOT MBUS_INC THEN 7 #DEFINE MBUS_MODULE_MEDIA 1 8 #DEFINE MBUS_MODULE_PATH "B:\SYSTEM\EXT\MOD_MBUS.RMX" 10 #DEFINE MBUS_DATA_LENGTH 246 12 #DEFINE MBUS_MODCALL_ERR -999 14 #DEFINE MBUS_MODE_S2 0 15 #DEFINE MBUS_MODE_T1 1 16 #DEFINE MBUS_MODE_T2 2 17 #DEFINE MBUS_MODE_S1 3 19 #DEFINE MBUS_MODE_T1_C 10 20 #DEFINE MBUS_MODE_T2_C 11 41 STRUCT_BLOCK ALIGN mbusFrame;
73 FUNCTION ALIGN mbusInit : INT;
75 showTags : BOOL := FALSE;
76 path : STRING := MBUS_MODULE_PATH;
77 media : SINT := MBUS_MODULE_MEDIA;
87 rc := fsMediaOpen(media := media);
89 DebugFmt(message := "Failed to open media \1 (err \2)", v1 := media, v2 := rc);
95 DebugMsg(message := "Extension: " + path);
96 FOR index := 1 TO 10 DO
98 rc:=extTagEnumerate(path:=path, index:=index, tag:=tag);
101 rc := extTagRead(path:=path,tag:=tag,text:=text);
103 DebugFmt(message := "[\1] : '" + strLeft(str := tag + "' ", length := 13) + "= '" + text + "'", v1 := index);
105 DebugFmt(message := "[\1] : Failed to read '" + tag + "' (err \2)", v1 := index, v2 := rc);
111 DebugFmt(message := "[\1] : Failed to read tag name (err \2)", v1 := index, v2 := rc);
119 rc := extModuleLoad(path:=path);
121 DebugFmt(message := "Failed to load module " + path + "(err \1)", v1 := rc);
126 DebugMsg(message := "Module '" + path + "' loaded");
148 mode: SINT := MBUS_MODE_T1;
155 IF NOT (error = 0) THEN
156 DebugFmt(message := "MBUS: failed to call external module 'mbusOpen' (err \1)", v1 := error);
157 mbusOpen := MBUS_MODCALL_ERR;
180 IF NOT (error = 0) THEN
181 DebugFmt(message := "MBUS: failed to call external module 'mbusClose' (err \1)", v1 := error);
182 mbusClose := MBUS_MODCALL_ERR;
213 IF NOT (error = 0) THEN
214 DebugFmt(message := "MBUS: failed to call external module 'mbusSend' (err \1)", v1 := error);
215 mbusSend := MBUS_MODCALL_ERR;
239 frame : ACCESS mbusFrame;
244 mbusReceive := INT(MODCALL("mod_mbus", "mbusReceive", error));
245 IF NOT (error = 0) THEN
246 DebugFmt(message := "MBUS: failed to call external module 'mbusReceive' (err \1)", v1 := error);
247 mbusReceive := MBUS_MODCALL_ERR;
279 FUNCTION mbusInfo : INT;
283 mbusInfo := INT(MODCALL("mod_mbus", "mbusInfo", error));
284 IF NOT (error = 0) THEN
285 DebugFmt(message := "MBUS: failed to call external module 'mbusInfo' (err \1)", v1 := error);
286 mbusInfo := MBUS_MODCALL_ERR;
312 FUNCTION mbusRegisterSlave : INT;
315 manufacturer : MANDATORY INT;
317 version : MANDATORY SINT;
318 type : MANDATORY SINT;
324 mbusRegisterSlave := INT(MODCALL("mod_mbus", "mbusRegisterSlave", error));
325 IF NOT (error = 0) THEN
326 DebugFmt(message := "MBUS: failed to call external module 'mbusRegisterSlave' (err \1)", v1 := error);
327 mbusRegisterSlave := MBUS_MODCALL_ERR;
346 FUNCTION mbusSetFilter : INT;
348 installed : BOOL := TRUE;
353 mbusSetFilter := INT(MODCALL("mod_mbus", "mbusSetFilter", error));
354 IF NOT (error = 0) THEN
355 DebugFmt(message := "MBUS: failed to call external module 'mbusSetFilter' (err \1)", v1 := error);
356 mbusSetFilter := MBUS_MODCALL_ERR;
static int mbusOpen(int8 mode, int8 rssi)
Opens the connection to the M-Bus module.
static int mbusSend(int16 c, int8 *data, int8 size)
Send an M-BUS packet.
static int mbusReceive(tdef_mbus_start_frame *start, int8 *data, int16 *rssi)
Receive a new frame from the M-Bus module.
static int mbusClose(void)
Closes the communication interface.
#define MBUS_DATA_LENGTH
Maximum size of a MBUS message not including header information.