If I create a file with CreateFile(), am I able to see it listed anywhere on the brick? I can see it using file explorer, but I can't seem to find it anywhere on the brick menu. Using enhanced NXC FW 1.31.
ROSCO
NXC: Using CreateFile()
Re: NXC: Using CreateFile()
Unless it is a
You may be interested in my NXTFileManager.
.rso
or .rxe
file, the NXT Standard/Enhanced Firmwares do not currently support the display of other formats. They still 'exist', however.You may be interested in my NXTFileManager.
Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE
Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Re: NXC: Using CreateFile()
Thanks for the info. It'd be great to be able to at least see the size of other files, see my next question:
I have another question about creating files. I'm attempting to create a file of size 4360. When I run it, the program fails. I've included the code below. If I comment out the loop that writes to the file (ie: only CreateFile() and CloseFile() are executed), it creates a file that is zero bytes (at least when I upload to the PC using NXT explorer the resulting PC file is zero btyes). If I leave the write loop in, the program exits with code -1, and a file of 1800 bytes is created (the file_size is correctly computed to be 4360). If I run it with an array shorter than 225 (1800 / 8) it seems to work happily.
Is there a limit on file size? I don't think I'm running out of flash memory because I can run it multiple times with new file names and it keeps creating the new files, all 1800 bytes.
Thanks for any info.
ROSCO
create-file.nxc:
dec_n23.nxc:
I have another question about creating files. I'm attempting to create a file of size 4360. When I run it, the program fails. I've included the code below. If I comment out the loop that writes to the file (ie: only CreateFile() and CloseFile() are executed), it creates a file that is zero bytes (at least when I upload to the PC using NXT explorer the resulting PC file is zero btyes). If I leave the write loop in, the program exits with code -1, and a file of 1800 bytes is created (the file_size is correctly computed to be 4360). If I run it with an array shorter than 225 (1800 / 8) it seems to work happily.
Is there a limit on file size? I don't think I'm running out of flash memory because I can run it multiple times with new file names and it keeps creating the new files, all 1800 bytes.
Thanks for any info.
ROSCO
create-file.nxc:
Code: Select all
#include "dec_n23.nxc"
float Test_1[][] = {
{0,0},
{2,1},
{5,4},
{10,5},
{15,4},
{18,1},
{20,0},
};
#define FILE_NAME "pks-n23"
#define ARRAY_NAME dec_n23
task main() {
// Find length of float
float x = 5.16534;
string y = FlattenVar(x);
int float_len = strlen(y);
// Find file length
unsigned int arr_len = ArrayLen(ARRAY_NAME);
unsigned int file_size = arr_len * 2 * float_len;
byte file_handle;
// Create file
unsigned int result = CreateFile(FILE_NAME, file_size, file_handle);
// Write data
for (int i=0; (i<arr_len) && (result == LDR_SUCCESS); i++) {
float p0 = ARRAY_NAME[i][0];
float p1 = ARRAY_NAME[i][1];
result = Write(file_handle, p0);
if (result == LDR_SUCCESS) {
result = Write(file_handle, p1);
}
}
// Close file
result = CloseFile(file_handle);
NumOut(0,LCD_LINE1,file_size);
NumOut(0,LCD_LINE2,result);
Wait (2000);
}
Code: Select all
float dec_n23[][] = {
{99.23,30.15},
{99.12,30.36},
{99,30.57},
{98.88,30.77},
{98.76,30.98},
{98.65,31.19},
{98.53,31.39},
{98.41,31.6},
{98.29,31.81},
{98.18,32.02},
{98.06,32.22},
{97.94,32.43},
{97.82,32.64},
{97.7,32.85},
{97.58,33.05},
{97.47,33.26},
{97.35,33.47},
{97.23,33.68},
{97.11,33.88},
{96.99,34.09},
{96.87,34.3},
{96.75,34.51},
{96.63,34.71},
{96.51,34.92},
{96.39,35.13},
{96.27,35.34},
{96.15,35.55},
{96.03,35.76},
{95.91,35.96},
{95.79,36.17},
{95.67,36.38},
{95.54,36.59},
{95.42,36.8},
{95.3,37.01},
{95.18,37.21},
{95.06,37.42},
{94.93,37.63},
{94.81,37.84},
{94.69,38.05},
{94.56,38.26},
{94.44,38.47},
{94.32,38.67},
{94.19,38.88},
{94.07,39.09},
{93.94,39.3},
{93.82,39.51},
{93.69,39.72},
{93.57,39.93},
{93.44,40.14},
{93.31,40.35},
{93.19,40.55},
{93.06,40.76},
{92.93,40.97},
{92.81,41.18},
{92.68,41.39},
{92.55,41.6},
{92.42,41.81},
{92.29,42.02},
{92.16,42.23},
{92.03,42.44},
{91.9,42.65},
{91.77,42.86},
{91.64,43.06},
{91.51,43.27},
{91.38,43.48},
{91.25,43.69},
{91.12,43.9},
{90.98,44.11},
{90.85,44.32},
{90.72,44.53},
{90.58,44.74},
{90.45,44.95},
{90.31,45.16},
{90.18,45.37},
{90.04,45.58},
{89.9,45.79},
{89.77,46},
{89.63,46.2},
{89.49,46.41},
{89.35,46.62},
{89.21,46.83},
{89.07,47.04},
{88.93,47.25},
{88.79,47.46},
{88.65,47.67},
{88.5,47.88},
{88.36,48.09},
{88.22,48.3},
{88.07,48.51},
{87.93,48.72},
{87.78,48.93},
{87.64,49.13},
{87.49,49.34},
{87.34,49.55},
{87.19,49.76},
{87.05,49.97},
{86.9,50.18},
{86.74,50.39},
{86.59,50.6},
{86.44,50.81},
{86.29,51.02},
{86.13,51.22},
{85.98,51.43},
{85.82,51.64},
{85.67,51.85},
{85.51,52.06},
{85.35,52.27},
{85.19,52.48},
{85.03,52.69},
{84.87,52.89},
{84.71,53.1},
{84.55,53.31},
{84.38,53.52},
{84.22,53.73},
{84.05,53.94},
{83.89,54.14},
{83.72,54.35},
{83.55,54.56},
{83.38,54.77},
{83.21,54.98},
{83.04,55.18},
{82.86,55.39},
{82.69,55.6},
{82.51,55.81},
{82.33,56.02},
{82.15,56.22},
{81.97,56.43},
{81.79,56.64},
{81.61,56.84},
{81.43,57.05},
{81.24,57.26},
{81.05,57.47},
{80.87,57.67},
{80.68,57.88},
{80.48,58.09},
{80.29,58.29},
{80.1,58.5},
{79.9,58.7},
{79.7,58.91},
{79.5,59.12},
{79.3,59.32},
{79.1,59.53},
{78.89,59.73},
{78.69,59.94},
{78.48,60.14},
{78.27,60.35},
{78.06,60.55},
{77.84,60.76},
{77.62,60.96},
{77.41,61.17},
{77.19,61.37},
{76.96,61.58},
{76.74,61.78},
{76.51,61.98},
{76.28,62.19},
{76.05,62.39},
{75.81,62.59},
{75.58,62.8},
{75.34,63},
{75.1,63.2},
{74.85,63.4},
{74.6,63.61},
{74.35,63.81},
{74.1,64.01},
{73.85,64.21},
{73.59,64.41},
{73.33,64.61},
{73.06,64.81},
{72.79,65.01},
{72.52,65.21},
{72.25,65.41},
{71.97,65.61},
{71.69,65.81},
{71.4,66.01},
{71.11,66.21},
{70.82,66.4},
{70.53,66.6},
{70.23,66.8},
{69.92,67},
{69.61,67.19},
{69.3,67.39},
{68.99,67.58},
{68.67,67.78},
{68.34,67.97},
{68.01,68.17},
{67.68,68.36},
{67.34,68.56},
{66.99,68.75},
{66.64,68.94},
{66.29,69.13},
{65.93,69.32},
{65.56,69.52},
{65.19,69.71},
{64.81,69.9},
{64.43,70.08},
{64.04,70.27},
{63.65,70.46},
{63.24,70.65},
{62.83,70.83},
{62.42,71.02},
{62,71.21},
{61.57,71.39},
{61.13,71.57},
{60.69,71.76},
{60.24,71.94},
{59.78,72.12},
{59.31,72.3},
{58.84,72.48},
{58.35,72.66},
{57.86,72.84},
{57.36,73.01},
{56.85,73.19},
{56.33,73.36},
{55.79,73.54},
{55.25,73.71},
{54.7,73.88},
{54.14,74.05},
{53.57,74.22},
{52.99,74.39},
{52.4,74.56},
{51.79,74.72},
{51.18,74.88},
{50.55,75.05},
{49.91,75.21},
{49.25,75.37},
{48.59,75.53},
{47.91,75.68},
{47.21,75.84},
{46.51,75.99},
{45.79,76.14},
{45.05,76.29},
{44.3,76.44},
{43.53,76.58},
{42.75,76.72},
{41.96,76.87},
{41.15,77},
{40.32,77.14},
{39.47,77.28},
{38.61,77.41},
{37.74,77.54},
{36.84,77.66},
{35.93,77.79},
{35,77.91},
{34.06,78.03},
{33.09,78.14},
{32.11,78.26},
{31.11,78.37},
{30.1,78.47},
{29.06,78.58},
{28.01,78.68},
{26.95,78.77},
{25.86,78.87},
{24.76,78.96},
{23.64,79.04},
{22.5,79.12},
{21.35,79.2},
{20.19,79.28},
{19,79.35},
{17.81,79.41},
{16.6,79.47},
{15.38,79.53},
{14.14,79.58},
{12.89,79.63},
{11.64,79.68},
{10.37,79.72},
{9.09,79.75},
{7.81,79.78},
{6.52,79.81},
{5.22,79.83},
{3.92,79.85},
{2.61,79.86},
{1.31,79.87},
{0,79.87},
{-1.31,79.87},
{-2.61,79.86},
{-3.92,79.85},
{-5.22,79.83},
{-6.52,79.81},
{-7.81,79.78},
{-9.09,79.75},
{-10.37,79.72},
{-11.64,79.68},
{-12.89,79.63},
{-14.14,79.58},
{-15.38,79.53},
{-16.6,79.47},
{-17.81,79.41},
{-19,79.35},
{-20.19,79.28},
{-21.35,79.2},
{-22.5,79.12},
{-23.64,79.04},
{-24.76,78.96},
{-25.86,78.87},
{-26.95,78.77},
{-28.01,78.68},
{-29.06,78.58},
{-30.1,78.47},
{-31.11,78.37},
{-32.11,78.26},
{-33.09,78.14},
{-34.06,78.03},
{-35,77.91},
{-35.93,77.79},
{-36.84,77.66},
{-37.74,77.54},
{-38.61,77.41},
{-39.47,77.28},
{-40.32,77.14},
{-41.15,77},
{-41.96,76.87},
{-42.75,76.72},
{-43.53,76.58},
{-44.3,76.44},
{-45.05,76.29},
{-45.79,76.14},
{-46.51,75.99},
{-47.21,75.84},
{-47.91,75.68},
{-48.59,75.53},
{-49.25,75.37},
{-49.91,75.21},
{-50.55,75.05},
{-51.18,74.88},
{-51.79,74.72},
{-52.4,74.56},
{-52.99,74.39},
{-53.57,74.22},
{-54.14,74.05},
{-54.7,73.88},
{-55.25,73.71},
{-55.79,73.54},
{-56.33,73.36},
{-56.85,73.19},
{-57.36,73.01},
{-57.86,72.84},
{-58.35,72.66},
{-58.84,72.48},
{-59.31,72.3},
{-59.78,72.12},
{-60.24,71.94},
{-60.69,71.76},
{-61.13,71.57},
{-61.57,71.39},
{-62,71.21},
{-62.42,71.02},
{-62.83,70.83},
{-63.24,70.65},
{-63.65,70.46},
{-64.04,70.27},
{-64.43,70.08},
{-64.81,69.9},
{-65.19,69.71},
{-65.56,69.52},
{-65.93,69.32},
{-66.29,69.13},
{-66.64,68.94},
{-66.99,68.75},
{-67.34,68.56},
{-67.68,68.36},
{-68.01,68.17},
{-68.34,67.97},
{-68.67,67.78},
{-68.99,67.58},
{-69.3,67.39},
{-69.61,67.19},
{-69.92,67},
{-70.23,66.8},
{-70.53,66.6},
{-70.82,66.4},
{-71.11,66.21},
{-71.4,66.01},
{-71.69,65.81},
{-71.97,65.61},
{-72.25,65.41},
{-72.52,65.21},
{-72.79,65.01},
{-73.06,64.81},
{-73.33,64.61},
{-73.59,64.41},
{-73.85,64.21},
{-74.1,64.01},
{-74.35,63.81},
{-74.6,63.61},
{-74.85,63.4},
{-75.1,63.2},
{-75.34,63},
{-75.58,62.8},
{-75.81,62.59},
{-76.05,62.39},
{-76.28,62.19},
{-76.51,61.98},
{-76.74,61.78},
{-76.96,61.58},
{-77.19,61.37},
{-77.41,61.17},
{-77.62,60.96},
{-77.84,60.76},
{-78.06,60.55},
{-78.27,60.35},
{-78.48,60.14},
{-78.69,59.94},
{-78.89,59.73},
{-79.1,59.53},
{-79.3,59.32},
{-79.5,59.12},
{-79.7,58.91},
{-79.9,58.7},
{-80.1,58.5},
{-80.29,58.29},
{-80.48,58.09},
{-80.68,57.88},
{-80.87,57.67},
{-81.05,57.47},
{-81.24,57.26},
{-81.43,57.05},
{-81.61,56.84},
{-81.79,56.64},
{-81.97,56.43},
{-82.15,56.22},
{-82.33,56.02},
{-82.51,55.81},
{-82.69,55.6},
{-82.86,55.39},
{-83.04,55.18},
{-83.21,54.98},
{-83.38,54.77},
{-83.55,54.56},
{-83.72,54.35},
{-83.89,54.14},
{-84.05,53.94},
{-84.22,53.73},
{-84.38,53.52},
{-84.55,53.31},
{-84.71,53.1},
{-84.87,52.89},
{-85.03,52.69},
{-85.19,52.48},
{-85.35,52.27},
{-85.51,52.06},
{-85.67,51.85},
{-85.82,51.64},
{-85.98,51.43},
{-86.13,51.22},
{-86.29,51.02},
{-86.44,50.81},
{-86.59,50.6},
{-86.74,50.39},
{-86.9,50.18},
{-87.05,49.97},
{-87.19,49.76},
{-87.34,49.55},
{-87.49,49.34},
{-87.64,49.13},
{-87.78,48.93},
{-87.93,48.72},
{-88.07,48.51},
{-88.22,48.3},
{-88.36,48.09},
{-88.5,47.88},
{-88.65,47.67},
{-88.79,47.46},
{-88.93,47.25},
{-89.07,47.04},
{-89.21,46.83},
{-89.35,46.62},
{-89.49,46.41},
{-89.63,46.2},
{-89.77,46},
{-89.9,45.79},
{-90.04,45.58},
{-90.18,45.37},
{-90.31,45.16},
{-90.45,44.95},
{-90.58,44.74},
{-90.72,44.53},
{-90.85,44.32},
{-90.98,44.11},
{-91.12,43.9},
{-91.25,43.69},
{-91.38,43.48},
{-91.51,43.27},
{-91.64,43.06},
{-91.77,42.86},
{-91.9,42.65},
{-92.03,42.44},
{-92.16,42.23},
{-92.29,42.02},
{-92.42,41.81},
{-92.55,41.6},
{-92.68,41.39},
{-92.81,41.18},
{-92.93,40.97},
{-93.06,40.76},
{-93.19,40.55},
{-93.31,40.35},
{-93.44,40.14},
{-93.57,39.93},
{-93.69,39.72},
{-93.82,39.51},
{-93.94,39.3},
{-94.07,39.09},
{-94.19,38.88},
{-94.32,38.67},
{-94.44,38.47},
{-94.56,38.26},
{-94.69,38.05},
{-94.81,37.84},
{-94.93,37.63},
{-95.06,37.42},
{-95.18,37.21},
{-95.3,37.01},
{-95.42,36.8},
{-95.54,36.59},
{-95.67,36.38},
{-95.79,36.17},
{-95.91,35.96},
{-96.03,35.76},
{-96.15,35.55},
{-96.27,35.34},
{-96.39,35.13},
{-96.51,34.92},
{-96.63,34.71},
{-96.75,34.51},
{-96.87,34.3},
{-96.99,34.09},
{-97.11,33.88},
{-97.23,33.68},
{-97.35,33.47},
{-97.47,33.26},
{-97.58,33.05},
{-97.7,32.85},
{-97.82,32.64},
{-97.94,32.43},
{-98.06,32.22},
{-98.18,32.02},
{-98.29,31.81},
{-98.41,31.6},
{-98.53,31.39},
{-98.65,31.19},
{-98.76,30.98},
{-98.88,30.77},
{-99,30.57},
{-99.12,30.36},
{-99.23,30.15},
};
-
- Posts: 358
- Joined: 01 Oct 2010, 06:37
- Location: Denmark
- Contact:
Re: NXC: Using CreateFile()
I think you are running into some bug totally unrelated to file IO. The program suddenly misbehaves, crashes, or even freezes the NXT when small changes are introduced. So I suspect it is some kind of firmware or compiler issue, perhaps because of the large array. (The complier creates 545 temporary arrays in order to build it.)
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
Re: NXC: Using CreateFile()
That last comment actually helped, thanks! I converted it into 2 single dimension arrays and it now works for that set. Larger arrays seem to crash it now (clicking), but I will try splitting them into smaller chunks and using OpenFileAppend().spillerrec wrote:I think you are running into some bug totally unrelated to file IO. The program suddenly misbehaves, crashes, or even freezes the NXT when small changes are introduced. So I suspect it is some kind of firmware or compiler issue, perhaps because of the large array. (The complier creates 545 temporary arrays in order to build it.)
Thanks!
ROSCO
Who is online
Users browsing this forum: No registered users and 0 guests