Robot App Store

image description

Robopedia

LEGO NXT FileWrite returns 0x84 error


Question


I keep getting the 0x84 error- End of file expected, from the FileWrite command (0x83).

The amount of bytes that are sent using the FileWrite command are the same as I’ve used when creating the file.
The file is opened for writing;

What am I missing here?

Answer


There are several possible reasons for the 0x84 error when using the FileWrite after creating a file:
  • Small file size- the actual size of the file that has just been created is smaller than you’ve expected.
    This may be caused by a wrong file create command arguments- The size argument contains 4 bytes LSB first.
    If the bytes are mixed (MSB first), the file that is created will be different;
  • Wrong FileWrite command length- NXT communication protocol can accept commands that their total length is smaller than 64 bytes.
    Use multiple FileWrite commands for a bigger data length;
  • Missing NULL terminator- If you are using a textual file, make sure that a NULL terminator (0x00) is added at the end of the data;

In order to use the FileWrite command successfully, make sure that:
  • You are using the right command to create the file.
    0x8B TextFileOpenWriteCreate- for textual files (txt and log extensions);
    0x89 LinearFileOpenWriteCreate- for executable files and for icons (rxe, sys, rpg, rtm, ric file types);
    0x81 FileOpenWriteCreate- for the rest of the file types;
    Check the correct syntax below;
  • The name of the file in the file create command is exactly 19 characters and 0x00 byte as NULL terminator.
    In case the file name is less than 19 characters, add 0x00 byte for each missing character.
    The bytes of file name and type characters should be ASCII encoded.
  • The file size is constructed from 4 bytes. LSB first. Check how to convert decimal to a byte array (MSB first) at the Robopedia and reverse the array to get the LSB first;
  • The file create command size is exactly 26 bytes 0x1A 0x00;
  • There is enough space for this size;
  • FileWrite length is less or equal to 64 bytes. Use multiple FileWrite commands for a bigger data length;
  • Call the FileClose command to save changes and prevent from the firmware to close the file automatically and reduce its size (if you need the extra space for future edit);

The syntax of the TextFileOpenWriteCreate command is:
[0x1A] [0x00] [0x01][0x8B] [fileName.fileType] [File size LSB] [...] [...] [File size MSB]

For more information about this command and its arguments check the file handling – create files tutorial.

The syntax of the LinearFileOpenWriteCreate command is:
[0x1A] [0x00] [0x01][0x89] [fileName.fileType] [File size LSB] [...] [...] [File size MSB]

For more information about this command and its arguments check the file handling – create files tutorial.

The syntax of the FileOpenWriteCreate command is:
[0x1A] [0x00] [0x01][0x81] [fileName.fileType] [File size LSB] [...] [...] [File size MSB]

For more information about this command and its arguments check the file handling – create files tutorial.

The syntax of the FileWrite command is:
[0x04 - ???] [0x00- ???] [0x01 or 0x81] [0x83] [Handle id] [Data]

For more information about this command and its arguments check the file handling – write to file tutorial.

The syntax of the FileClose command is:
[0x03] [0x00] [0x01 or 0x81] [0x84] [Handle id]

For more information about this command and its arguments check the file handling – save and close tutorial.

For more error codes and their explanation, check the what is a Bluetooth telegram tutorial.
married and want to cheat married men having affairs my wife cheated on me with my father



Related Robopedia portals

Find out further reading in the following topic-based portals.
[Add or Edit Article]