fsMediaOpen (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

1.00 / 1.00.00


This opens the media for use by the file system. Calling this function is required before the file system can be used.

Once a media is opened with this function, that media is available for all threads.

 

This table show how the medias are identified in VPL:

 

 

Media

ID

Drive

SD-CARD

0

A:

Internal drive

1

B:

Project drive

2

P:

USB drive

3

U:

 

Please note that the default media at device start-up is always the SD-CARD (A:) drive. This means that if only the internal drive is used, the current drive must be changed from A: to B: by using fsDirChange or absolute path specifications must be used.

 

 

Also see fsMediaClose for closing the media when finished with the operations.

 

 

Input:                

media : INT (0..3)

The media to open.

 

Returns: INT

0

Media is opened.

-1

Invalid media ID.

-15

The specified media is not available.

 

Declaration:

FUNCTION fsMediaOpen : INT;
VAR_INPUT
  media : INT;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  fd : FILE;
END_VAR;
 
fsMediaOpen(media := 0);
BEGIN
  ...
  IF fsFileExists(name := "gpslog.dat") THEN
     fd := fsFileOpen(name := "gpslog.dat");
  ELSE
     fd := fsFileCreate(name := "gpslog.dat");
  END_IF;
  ...
END;
END_PROGRAM;