Since I use Connectport X5 and this device does not have a usb port, I cannot test the USB drive code. I really want to know what is the exact address for the internal flash of Digi Connectport device.
I tried to create a file and upload under the Applications
->Python. Then I tried to open the file by using “fh = open(“WEB/python/tmp.txt”, ‘w’)”. But it still reports no file exist…
Since I worte that Wiki page, I know that the code works.
“fh = open(“WEB/python/tmp.txt”, ‘w’)” would delete an existing file. So if you uploaded tmp.txt via the web interface, then tried to ‘open’ it for writing, it would be truncated. Did you mean you wish to open it for reading?
The “WEB/python” prefix is true on all Digi gateways - X2, X3, X4, X5 and X8. It is case senstive and cannot start with a /, so “/WEB/python” and “WEB/Python” are both wrong.
“fh = open(“WEB/python/ddd.txt”, ‘r’)
print (fh.read())”
I tried this two line code right now. However, still report no file exists. I am sure I upload a ddd.txt file in both the Python and file management… Also I want to know how to run/test the code here: http://www.digi.com/wiki/developer/index.php/Read_and_Write_Flash_USB?
To test that code, you need to be compenetnt in Python so that you can create your own database object, then add those functions as methods under it. The routines shown are cut from an actual data-point logger for a tank monitoring system. The full module/file is not mine to publish; it is not public domain.
Make sure you are not issuing an os.chdir, as that will screw up the paths (if your X5 firmware is new, older firmware didn’t support chdir()).
And I think my problem is I cannot locate the file system when I use directory “WEB/python”. Everytime I try to open a file it will report “File does not exist”.