if M552 S1 fails; send M552 S2? Is this possible with RRF3??
-
Has this been done yet???
Eliminate the need to connect via USB
Instead of needing to connect to the Duet 2 Wifi via USB, the Duet 2 Wifi can first attempt to connect to a network.. but if the parameters don't exist, or have changed, and the connection fails it can then send its own wifi signal.
If it sends its own wifi signal you can then connect to the Duet via your cellphone/computer and modify the network settings & reboot.
RRF 3.01 introduced "GCode Meta Commands" (https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands) or if, elif, else, loops, etc.
If something like this works I think it would help a ton of people! I'm thinking it will exist in either the top of config.g or as a macro, called toward the top of config.g
What do you guys think? Ideas? opinions? is it impossible? why?
-
i think you can do (or something close to that).
if network.interfaces[0].actualIP = "0.0.0.0" M552 S-1 M552 S2
might want to add some
M291
,G4
orwhile state.upTime <
to give wifi some time to connect before reverting -
Wouldn't you need to define network.interfaces? or is this defined somewhere and I've missed it?
-
it shoud be an existing array for any duet with at least one network interface.
check out M409 to query the object model at run time.
https://duet3d.dozuki.com/Wiki/Gcode#Section_M409_Query_object_model
(edit: i think i recall reading somewhere that during execution of config.g M552 is defered until the end, so you may have to resort to using daemon.g)
-
this is the macro I put together:
;Attempt to connect to wifi signal, if it fails, emit a wifi signal
M552 S0 ; set wifi module to idle
G4 S3 ; dwell 3 seconds
M552 S1 ; connect to predefined network
G4 S10 ; dwell 5 secondsif network.inferfaces[0].actualIP = "0.0.0.0":
M552 S0 ; set module to idle
G4 S3 ; dwell 3 seconds
M587 SEve Ppassword I192.168.0.133 ; define parameters for wifi signal
G4 S1 ; dwell 1 second
M552 S2 ; emit wifi signalM586 P0 S1 ; enable HTTP
M586 P1 S0 ; disable FTP
M586 P2 S0 ; disable Telnetbut I get the error :
Error: in file macro line 9 column 4: meta command: unknown value 'inferfaces^.actualIP'I'm thinking the "if" statement needs a parameter which is only true when the machine fails to connect to a wifi signal, but I'm not sure what this parameter would be
-
maybe you need to test if network.interfaces is null or not as well. do some poking with M409 and look at how the object model changes before and after.
-
I do not know if this will work in RRF3 conditional code, but you could try doing
if network.interface[0].actualIP ; don't do anything else ; do the thing you want to do if no IP is acquired
In some (most?) languages, if a value is null (or nil) it evaluates as false.
I could be making no sense right now so ignore me if it seems appropriate.
-
I did some poking with M409, took me a little while to figure out, but I think you were completely right originally bearer with the "network.interfaces[0].actualIP". If the board fails to connect the actualIP does turn to 0.0.0.0
Here's where I'm at now:
;Attempt to connect to wifi signal, if it fails, emit a wifi signal
M552 S0 ; set wifi module to idle
G4 S3 ; dwell 3 seconds
M552 S1 ; connect to predefined network
G4 S10 ; dwell 5 secondsif network.interfaces[0].actualIP = "0.0.0.0"
M552 S-1 ; turn off wifi module
G4 S3 ; dwell 3 seconds
M552 S0 ; set module to idle
G4 S3 ; dwell 3 seconds
M589 S"Eve" P"password" I192.168.0.133 ; define parameters for access point (AP)
G4 S1 ; dwell 1 second
M552 S2 ; emit access pointM586 P0 S1 ; enable HTTP
M586 P1 S0 ; disable FTP
M586 P2 S0I get an error seen below:
Error: in file macro line 9 column 46: meta command: cannot convert operands to same typeWhat does it mean by cannot convert operand to same type?
I like your idea bot, I think that'd be a good "final" but right now I'm trying to get it working as a macro
-
@Ben said in if M552 S1 fails; send M552 S2? Is this possible with RRF3??:
cannot convert operands to same type
would help to run m409 on network.interfaces[0].actualIP and/or network.interfaces to see what the status is as the error must be in relation to the type of network.interfaces[0].actualIP not matching the type of string "0.0.0.0" we're trying to compare it to
-
@bearer is this what you mean?
M409 K"network.interfaces[0].actualIP"
{"key":"network.interfaces[0].actualIP","flags":"","result":"192.168.0.133"}<LF>ok<LF>M552 S-1
WiFi module stopped<LF>ok<LF>M558 S0
ok<LF>M588 S"*"
ok<LF>(unplugged the machine, replugged it in)
M409 K"network.interfaces[0].actualIP"
{"key":"network.interfaces[0].actualIP","flags":"","result":"0.0.0.0"}<LF>ok<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported err[Warning: Maximal number of bytes per line exceeded! Check the EOL (end-of-line) settings or increase the limit in the advanced terminal settings.] -
sorry maybe i was unclear I meant to insert m409 on the line above the if statement so we get to see exactly what the value is immediately before the error is. but it looks to be a string to me, but I can't say I've played much with the object model so maybe someone else has a better idea.
-
ah, my bad I see what you mean. I inserted the M409 command in as so:
G4 S10 ; dwell 5 seconds
M409 K"network.interfaces[0].actualIP"
if network.interfaces[0].actualIP = "0.0.0.0"
M552 S-1 ; turn off wifi moduleand got the feedback:
7/11/2020, 2:17:46 PM {"key":"network.interfaces[0].actualIP","flags":"","result":"192.168.0.133"}Error: in file macro line 11 column 46: meta command: cannot convert operands to same type
I appreciate your help @bearer !
-
I think I see the problem. The value network.interfaces[0].actualIP has type IPAddress, whereas "192.168.0.133" has type String. So the two cannot be compared directly.
However, if you apply the string concatenation operator to an IPAddress, it will convert it to type String. So you can use this instead:
if (network.interfaces[0].actualIP^"Q") = "0.0.0.0Q"
-
@dc42 said in if M552 S1 fails; send M552 S2? Is this possible with RRF3??:
has type IPAddress
how can we tell?
(and I presume 3.2 will result in an update of https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands#Section_Types if there any other interesting developments)
-
@bearer said in if M552 S1 fails; send M552 S2? Is this possible with RRF3??:
how can we tell?
The Object Model Browser plugin for DWC 3.2 will display the types as well as the values.
-
@dc42 said in if M552 S1 fails; send M552 S2? Is this possible with RRF3??:
Browser plugin
understatement:
-
@dc42 said in if M552 S1 fails; send M552 S2? Is this possible with RRF3??:
if (network.interfaces[0].actualIP^"Q") = "0.0.0.0Q"
Hey this worked!!! I appreciate you!
I changed the parameters of the if statement from actualIP to changingMode:
So I'm now using:
if (network.interfaces[0].state^"Q") = "changingModeQ"emit predefined access point
I found that while duet is in M552 S1 mode and can't find a wifi signal, it's actually in "changing mode" As of right now I like this parameter over assuming the IP, as sometimes the IP wouldn't be "0.0.0.0"
-
Glad you have it working!
Though, is
network.interfaces[0].state
not a string type? If it's a string, the concatenation is likely unneeded. -
@bot yes you are right. The macro works without converting it to a string.
-
@bearer You were right about the daemon.g ... I tried to call the macro from the config.g, or just run it straight from the config.g but neither worked, I think you're right that M552 is delayed.
I couldn't find a lot of documentation on daemon.g out there, but I made the daemon.g file in the /sys folder and called the macro "WIFICONNECT" from it. From my understanding the daemon.g file is running constantly in the background? Will this harm anything in the long run? Right now I suspect if there is a temporary "lag" or disconnect with the wifi it will automatically emit it's own wifi signal.. which would inconvenient.
Here's my daemon.g:
G4 S30M98 P"WIFICONNECT"
Here's what I have working for the WIFICONNECT macro:
;Attempt to connect to wifi signal, if it fails, emit a wifi signal
G60if (network.interfaces[0].state) = "changingMode" ; if unable to find/connect to network, emit network access point
M552 S-1 ; turn off wifi module
G4 S3 ; dwell 3 seconds
M552 S0 ; turn wifi module to idle
G4 S3 ; dwell 3 seconds
M552 S2 ; emit predefined access point
M586 P0 S1 ; enable HTTP
M586 P1 S0 ; disable FTP
M586 P2 S0 ; disable Telnet