Change IP address via server-side include

Using a AB4173, version 2.19.2, type ABS-EIP.

I am having problems getting the SSI mechanism to work from my javascript. Has anyone used the module’s StoreEtnConfig server-side include mechanism successfully, and, if so, would be willing to share the html/js example?

Thanks in advance.

I can get other SSI commands to work, but I am having difficulty with the above.

What I’m using is as follows. Any help would be greatly appreciated.

-Mike


// [1] html with displayable content

function onChngIPto4()
{
var form = new FormData();
form.append(“SetIp”, “192.168.3.4”);

xmlHttpReqRX.open('POST', "unitInfoWRITE_IP.htm?"+Math.random());//added [?"+Math.random()] after page name for no caching in IE browser
xmlHttpReqRX.send(form);

}

[2] unitInfoWRITE_IP.htm content

<?--#exec cmd_argument='StoreEtnConfig'-->

Hey Nick
new information:
turns out I can get it working if I change the [1] html with displayable content to the following.

however, it requires a reboot of the anybus-S. Is there a way that reboot could be achieved via SSI, so that no reboot is required [similar to the way HMS’s IpConfig tool is able to operate]?

function onChngIPto4()
{
var urlEncodedData = “”;
var urlEncodedDataPairs = [];

urlEncodedDataPairs.push("SetIp" + '=' + "192.168.3.4");

// Combine the pairs into a single string and replace all %-encoded spaces to 
// the '+' character; matches the behaviour of browser form submissions.
urlEncodedData = urlEncodedDataPairs.join('&').replace(/%20/g, '+');


xmlHttpReqRX.open('POST', "unitInfoWRITE_IP.htm?"+Math.random());//added [?"+Math.random()] after page name for no caching in IE browser
xmlHttpReqRX.send(urlEncodedData);

}

@mpalmer1223

Can you share the content of your unitInfoWrite_IP.htm file? I believe I have an easier way however I would like to compare.

Additionally, you can send the file via a private message as well.

Hi, Jordan - the content is the single line as shown in my initial entry in this thread. I pass the new values as a form.

This all seems to work now, but requires a reboot, unlike the way your IpConfig tool can change an ip address sans a re-init of the module.

[2] unitInfoWRITE_IP.htm content

<?--#exec cmd_argument='StoreEtnConfig'-->

@mpalmer1223

Issuing a follow-up request to /master/reboot.html should trigger a reboot on your hardware. I’ve tested on my device and it is working correctly.

Bear with me, Jordan…

I’m not understand you. Can you send me the specific Xml Http request you’re using?

Thanks

@mpalmer1223

I didn’t actually use an XmlHttp request but instead used an AJAX request via JQuery however if we were doing it via XMLHttp request something like this:

 function reboot(){
    xmlHttpReqRX.open('GET', "master/reboot.html", true);
    xmlHttpReqRX.send();
 }

ok, that’s specifically what I tried, too, but I get the following in Mozilla’s debugger.

XML Parsing Error: mismatched tag. Expected: .
Location: http://192.168.3.4/master/reboot.html
Line Number 7, Column 3:

I’m using:
var xmlHttpReqUnitInfo = new XMLHttpRequest();

function onReqReboot()
{
xmlHttpReqUnitInfo.open(‘GET’, “master/reboot.html”, true);
xmlHttpReqUnitInfo.send();
}

@mpalmer1223

Try this (direct copy paste) this worked fine for me. You appear to be using some invalid characters in your function.

var xmlHttpReqUnitInfo = new XMLHttpRequest();
function onReqReboot()
{
    xmlHttpReqUnitInfo.open('GET', 'master/reboot.html', true);
    xmlHttpReqUnitInfo.send();
}

first off, I really appreciate the help and your patience. Thanks so much! I think we’re almost there…

I still get the same error, even when I cut copy paste per your suggestion. I don’t think it’s a syntax thing, since in a different Mozilla debug window, I also see the response after I issue that GET request.

It seems master/reboot.html is not on my web server. Is it once of the built-in, virtual pages? Did my storing my custom set of web pages override its visibility?

404 Not Found

Not Found

The requested URL was not found on this server.


@mpalmer1223

Absolutely not a problem! We are always here to help :slight_smile:

Can you tell me, how are you storing the files? Can you paste a quick and dirty file structure?

Are you able to reach the /master/reboot.html via a browser natively (non-code)?

We use an ftp / batch program to place all files in the attached layout into a virgin module’s file system.

I cannot reach /master/reboot.html via browser natively

The version of firmware in the Anybus-S is 2.19.2

filestruct.txt (5.5 KB)

@mpalmer1223

Ok the fact that you can’t reach the reboot page makes this a bit tougher. If you reboot the hardware directly from the webpage, what URL is called?

Sorry, I don’t understand your question.

I am unable to reboot the hardware directly from the web page [assuming you mean programmatically].

If I simply power off the module and host, then back up, index.html points at system_status.html, which is what is fetched correctly.

As a test, I also erased all my files off the Anybus-S eth-ip’s file system, so that the default HMS web server [virtual files, I guess?] would be displayed. At that point, if I try to manually reach reboot page, I also get 404 Not Found.

I am going to request that my colleagues review this issue, I will let you know when I have more information.

Are you in admin root when adding files to the file system from the FTP?

yes, I’m at the admin root the files are added.

Part of the confusion is that the X-gateway we were using for our testing has this reboot.html and other product specific files that are not standard in the ABS.

You can implement similar behavior in your application by doing an SSI operation to telling the Anybus-s to reboot.

The SSI commands for writing are on page 8-7,

Information on the software reset mailbox command are on page 57 of this manual,

Thanks, Nick. Again, much appreciation to you and Jordan’s time on this. I’ve got what I need, feel free to close this issue from your end if you need to. Have a good Wednesday.

Thank you, you too!