BackupGGCode / python-on-a-chip

p14p for short.
Other
1 stars 0 forks source link

Add file I/O to desktop/plat.py #31

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The desktop platform does not have a plat.py module.  This should be created 
for purposes of demonstration and utility.

Original issue reported on code.google.com by dwhall...@gmail.com on 2 May 2009 at 6:19

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago

Original comment by dwhall...@gmail.com on 26 Jul 2010 at 1:34

GoogleCodeExporter commented 9 years ago

Original comment by dwhall...@gmail.com on 12 Aug 2010 at 2:28

GoogleCodeExporter commented 9 years ago
Integrate Thomas Ng's File IO for the desktop (submitted via maillist 
2010/10/04).  I put it in a file and attached it to this issue

Original comment by dwhall...@gmail.com on 16 Oct 2010 at 7:28

Attachments:

GoogleCodeExporter commented 9 years ago
From Tyler Wilson via maillist on 2010/10/04:

When I saw this come through, I thought the same thing: it would be nice to 
have this in the Windows build, at the minimum for testing. So I just gave a 
quick shot incorporating Thomas' code in the Windows platform. Here are some 
notes:

- I put Thomas' code in a file.py in the Windows platform folder, and added 
that .py file to the pmImgCreator step when building the main_img.c and 
main_nat.c files.

- I added fcntl.h, io.h, sys/types.h and sys/stat.h and string.h includes to 
the Windows plat.h to allow the source to build.

- There is no bzero function in MS SDK. I changed it to the good old memset 
function. Note this is also suggested here: 
http://www.opengroup.org/onlinepubs/000095399/functions/bzero.html

- wrt to the 0666 flag on the open call, I re-read the docs here 
http://www.opengroup.org/onlinepubs/000095399/functions/open.html and note that 
open takes a variable number of parameters, with a minimum of two. So on 
Windows I changed that line to be simply:

       fd = open(ppath, fsf);

which appears to build just fine (untested though).

- wrt to the static buffer used in the module, I personally think it ought to 
be allocated from the main heap set aside in the main p14p module (part of the 
PM_HEAP_SIZE defined in plat.h). This way we know exactly where the memory is 
coming from, and it is easier to track how much memory is being used in the 
whole system; that is, it won't be 'hidden' anywhere.

- For the open, read, write and close calls, I get a number of annoying 
warnings about these functions being deprecated, suggesting the use of the ISO 
C++ versions, which are the same with a prepended '_'. So they become _open, 
_read, _write and _close. Can we use these instead? My understanding is that 
they should work on Linux/GCC as well (I will test with cygwin too).

Annoying Windows aside: I also define _CRT_SECURE_NO_WARNINGS since I get 
warnings about the basic _open function being insecure. Likely not a huge issue 
since we are not building highly secure apps, but just worth noting.

That should do it,
Tyler

Original comment by dwhall...@gmail.com on 16 Oct 2010 at 7:30

GoogleCodeExporter commented 9 years ago

Original comment by dwhall...@gmail.com on 22 Oct 2010 at 3:32