Skip to content

Commit 5610e3f

Browse files
fix: handle empty json from serial
1 parent 8a3d483 commit 5610e3f

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

data/flows.json

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@
893893
"type": "function",
894894
"z": "09012e75c72a4968",
895895
"name": "setSerial",
896-
"func": "msg.serial_id = \"/dev/ttyUSB0\"\nmsg.payload = JSON.parse(msg.payload)\nreturn msg;",
896+
"func": "msg.serial_id = \"/dev/ttyUSB0\"\nmsg.payload = parseJson(msg.payload)\n\nfunction parseJson(string) {\n return string === \"\" ? JSON.parse(\"{}\") : JSON.parse(string)\n}\n\nreturn msg;",
897897
"outputs": 1,
898898
"noerr": 0,
899899
"initialize": "",
@@ -1033,7 +1033,8 @@
10331033
"y": 180,
10341034
"wires": [
10351035
[
1036-
"ead8458e27835fd5"
1036+
"ead8458e27835fd5",
1037+
"df4e2787b740a95d"
10371038
]
10381039
]
10391040
},
@@ -1936,8 +1937,8 @@
19361937
"y": 1440,
19371938
"wires": [
19381939
[
1939-
"ad7cbc939ce76248",
1940-
"d84f8fb891cfb581"
1940+
"d84f8fb891cfb581",
1941+
"ad7cbc939ce76248"
19411942
]
19421943
]
19431944
},
@@ -1994,8 +1995,24 @@
19941995
"name": "Success: No content",
19951996
"statusCode": "204",
19961997
"headers": {},
1997-
"x": 2720,
1998+
"x": 2780,
19981999
"y": 1500,
19992000
"wires": []
2001+
},
2002+
{
2003+
"id": "df4e2787b740a95d",
2004+
"type": "debug",
2005+
"z": "09012e75c72a4968",
2006+
"name": "debug 1",
2007+
"active": true,
2008+
"tosidebar": true,
2009+
"console": false,
2010+
"tostatus": false,
2011+
"complete": "false",
2012+
"statusVal": "",
2013+
"statusType": "auto",
2014+
"x": 360,
2015+
"y": 140,
2016+
"wires": []
20002017
}
20012018
]

0 commit comments

Comments
 (0)