Read,Write Network File

logantvlogantv ProgrammerPosts: 12

I have a lot of systems on the same network, and a bunch of them are extremely similar. I want to be able to have a file on the network that they can read to change some of the variables. If, for instance, I want to change the nightly shutdown time, I'd rather have the masters read a CSV or whatever, rather than manually change all of them in debugger or with a recompile. I know how to read and write to a local file on the master, but from what I've seen I can't write to a Windows network location.

Before I reinvent the wheel, is anyone doing something similar? I can stick an NX-1200 or 2200 on the network and use it as a file server if I need to, but I'm assuming that would also require a huge list of master to masters. That's ok if it won't choke the "server", but ideally it would be a Windows or Linux location.

I played around with the FTP method mentioned on the forum, but I'd much rather just socket connect, and read the file if at all possible.

I'm good with how I'd format and parse the file, I just don't know the best way to actually access it. Thanks in advance for any help.

Comments

  • logantvlogantv Programmer Posts: 12
    edited August 18

    Sorry for answering myself, but is there a way to set a variable through Telnet? I know I can send something like "pulse[dvTP,1]", but if setting a variable through Telnet is possible I could maybe just push the changes straight from the computer holding the settings file.

    I guess I could do it like this:
    python on server:

    • connect telnet to master
    • telnet command: send_string vdvConfig,"'sShutdownTime=22:00:00',$0D"$0D //(or whatever)
    • exit telnet

    program:
    data_event[vdvConfig]
    {
    string:
    {
    vars and stuff to create a buffer
    sVarName = get_buffer_string(buffer,find_string(buffer,'=') - 1);
    get_buffer_char(buffer); //remove the =
    sValue = etc.
    }
    }

    This might be the way I go since I can push changes immediately, instead of handling 400+ systems potentially checking in at the same time, but I'm open to any ideas. Plus if it's some sort of global change, I could probably update everybody with a simple FOR loop on the server side.

  • John NagyJohn Nagy CineTouch Product Manager Posts: 1,526

    How about you just fetch a CSV data file by a web HTTP URL, use an old 700 or any web server as a repository and just make web calls to its IP address from your code. Same as if you were calling an image.... put in a randomizer for when they call in to get the new settings to avoid a traffic jam, and a retry after another random delay if it can't connect.

  • ericmedleyericmedley Senior Member - 3709 Posts Posts: 4,159

    The answer to both question above is 'yes' However, in both cases you'll need to essentially roll your own API. Probably the easiest wat to build the remote file reader is to write a simple FTP session manager to open and read the remote file. If you want to or can load the file on a Netlinx Master (as the file server) you can make the reader code on the Netlinx file server and use Netlinx code to pass on the values you want. The only thing to think about when using a PC based server is that if something happens where the ftp server alters its communication protocol even slightly - it can break your code without you knowing it happened. (like after a software update or something.)

    You might want to consider another method which is a bit more bullet-proof by using something that utilizes a method of just transferring the data without the whole 'file handling' Something like a XML sheet being serverd by a web server, or perhaps JSON or the like. Those protocols can be a bit more to chew but the connection and data transfer methods are pretty light-weight and fast.

    On the 'send a command' it's essentially the same thing as above but in reverse. You can create a quick IP Server on your master and write a quick API to convert telent commands to whatever you want. Over the years I've developed a little module I use that does just this to deal with some of the secure systems I've written that need to deal with the fact that the network is closed off and I need to do some master-to-master using rs232.

  • logantvlogantv Programmer Posts: 12

    Thank you both.

    I had played around with FTP but I know absolutely nothing about setting up an FTP server. I found how to enable it in Windows 10, and I also tried using FileZilla's server program on my PC as a guinea pig, but as soon as I started running into firewall issues I bailed since I don't HAVE to do it that way. FileZilla's server program could be great, but they're probably assuming you already know the basics like how to select the location you want to share. Maybe I'll figure all that out on a rainy day.

    I think my plan is to make a simple web page with pull down menus for campus, bldg, and room. Then I'll have some text and text boxes to enter settings, and a Send button that'll send_string (or send_command) via Telnet to the selected master similar to what I have above. I like getting to roll my own. At my previous employer I got to do a room that had an NI-4100, a Crestron DMPS3-300, and a Cisco SX80, with its Touch10 as the touch panel.

    As I think it through, I'll probably have to do the master check-in direction, too, if I want to be able to easily make global settings changes. Either that or a big slow Telnet FOR loop on the website/server. If I have the masters check in I'll definitely use the randomizer idea. I definitely don't want to handle that manually. As long as I make the variables persistent I should be good on power loss/reboots at least.

  • ericmedleyericmedley Senior Member - 3709 Posts Posts: 4,159

    FTP. You might try setting up a LINUX box to act as a server. Making it an FTP server is pretty easy.

  • logantvlogantv Programmer Posts: 12

    Good idea. That way there's tons of base code for FTP and Telnet out there.

Sign In or Register to comment.