Professional Documents
Culture Documents
Series 30i-Model A
Series 300i-Model A
Series 300is-Model A
C Language Executor
Operator’s Manual
Warning
Warning notices are used in this publication to emphasize that hazardous voltages, currents,
temperatures, or other conditions that could cause personal injury exist in this equipment or
may be associated with its use.
In situations where inattention could cause either personal injury or damage to equipment, a
Warning notice is used.
Caution
Caution notices are used where equipment might be damaged if care is not taken.
Note
Notes merely call attention to information that is especially significant to understanding and
operating the equipment.
This document is based on information available at the time of its publication. While efforts
have been made to be accurate, the information contained herein does not purport to cover all
details or variations in hardware or software, nor to provide for every possible contingency in
connection with installation, operation, or maintenance. Features may be described herein
which are not present in all hardware and software systems. GE Fanuc Automation assumes
no obligation of notice to holders of this document with respect to changes subsequently made.
Applied CNC
------------------------------------------------------
MODEL Abbreviated name
------------------------------------------------------
FANUC Series 30i-MODEL A 30i-A or Series 30i
Notes
* Microsoft, MS, Windows, NT, and the Windows logo are either trademarks or
registered trademarks of Microsoft Corporation.
Diab SDS , alone and in combination with D-CC are trademarks of Diab SDS,INC.
* Additionally, the described company name and the product name are the
registered trademark of each company or trademarks.
B-63944EN-3/01 TABLE OF CONTENTS
TABLE OF CONTENTS
I. SPECIFICATION
1. Overview ...............................................................................................3
1.1 Feature ..........................................................................................................4
2. System components.............................................................................6
2.1 C Executor .....................................................................................................6
2.2 C library..........................................................................................................7
2.3 Application program .......................................................................................8
2.4 The hardwares of CNC which are used in C Executor.................................11
3. Application program development environment..............................14
3.1 Composition of development system ...........................................................14
3.2 Development procedure...............................................................................16
4. C language library function list .........................................................18
4.1 ANSI C standard library ...............................................................................18
4.2 MS-C extended C standard library...............................................................21
4.3 Graphic library..............................................................................................22
4.4 CNC/PMC window library.............................................................................24
4.5 Other libraries ..............................................................................................26
II. PROGRAMMING
0. INDEX ..................................................................................................35
0.1 Required software for application development ...........................................37
1. List of Functions.................................................................................38
1.1 ANSI C Standard library...............................................................................38
1.3 Graphic library..............................................................................................46
1.4 CNC/PMC window library.............................................................................48
1.5 Other libraries ..............................................................................................51
2. How to make application program ....................................................59
2.1 Outline .........................................................................................................59
2.2 Special files..................................................................................................62
2.3 MAKEFILE ...................................................................................................63
2.4 Installing the Diab C/C++ Power-PC compiler .............................................65
2.5 Compatibility related to variables of type 'int' ...............................................66
c-1
TABLE OF CONTENTS B-63944EN-3/01
5 Other References..............................................................................727
5.1 Multitasking ................................................................................................727
5.1.1 Task classes ......................................................................................................... 727
5.1.2 Difference of each task class ............................................................................... 728
5.1.3 Task switching..................................................................................................... 728
5.1.4 Data access between tasks ................................................................................... 729
5.1.5 Task Management................................................................................................ 730
5.2 File system.................................................................................................731
5.3 Power-on procedure ..................................................................................734
c-2
B-63944EN-3/01 TABLE OF CONTENTS
c-3
I. SPECIFICATION
1. Overview
FANUC Series 30i C Executor enables to add the Machine Tool Builder's
original screen into FANUC Series 30i and to customize screen displaying and
operation interface of CNC software. It is possible to replace arbitrary
screens of CNC with user application's screen. The user application program
about screen displaying and operation interface is developed using general
C language just like ordinary PC's application program developing. The
executable file which is developed by the Machine Tool Builder is built in
CNC unit. The user program which is compiled on PC is stored in flash ROM of
CNC unit, and it is read into CNC's memory by CNC's start-up procedure, then,
executed on C Executor.
Application
program is
Application program stored in CNC software and the user application
is developed on PC. flash ROM. program is executed simultaneously.
+------------+ +----------------------------------+
| +--------+ | | |
| | | | | Series 30i |
| | PC | | | |
| +--------+ | |----------------------------------|
+------------+ +--------+ | User | C library | CNC |
+--------------+ | Memory | | Application | | Soft |
| == == | -> | Card | -> |----------------------------------|
+--------------+ +--------+ +----------------------------------+
|
|
+--------------------------+
| +----------+ oooooo |
Machine Tool Builder's | o |.... | oooooo |
original screen is | o |....... | oooooo |
displayed | |....... | oooooo |
| |----------| oooooo |
| +----------+ |
| o o o o o |
+--------------------------+
(LCD/MDI unit)
1.1 Feature
C Executor can be used with Macro Executor (Execution Macro and also
Conversational Macro) of Series 30i-A. The screen displaying part of macro
program which has been developed by the Machine Tool Builder can be replaced
with C program, therefore, existing software property does not become
useless. (C Executor doesn't have Execution Macro function.)
(10) Simultaneous displaying of CNC and user screen using window display
The user application program can display user window on the arbitrary
screens including the CNC screens using window display function (VGA window).
It is possible to display Machine Tool Builder's original message window
or the software machine operation panel on the existing CNC screen.
2. System components
The system components that C Executor and the user application program are
shown below.
2.1 C Executor
C Executor loads the user application program and C library from flash
ROM into DRAM in start-up procedure of CNC unit, and starts executing the
user application program.
Task switching between MAIN TASK and AUXILIARY TASK is done by calling
task control library function in application program. Periodically starting
of AUXILIARY TASK is also commanded in application program. It is possible
to compose application program with only one task. In this case, only MAIN
TASK is used.
WINDOW TASK
----------------------------------
Standard function x
Key input
Character display x (*1)
Graphic display x (*1)
File I/O
CNC/PMC window x (*2)
Reader/puncher
interface
Reading F-ROM
Reading touch-panel x
(*1) The target screen to output is not the ordinary screen but
VGA window.
(*2) It is necessary to contol exclusively with the other tasks.
For example, the program which consists of only Main task has following
structures.
++---------------++
|| main function ||
++-------+-------++
|
+----------+----------+
| Initialization |
+----------+----------+
|
+----------+----------+
| Setting of user |
| screens |
+----------+----------+
|
+----------+----------+
| Setting of softkeys |
| by which user |
| screens are selected|
+----------+----------+
| Repetition
|<----------------------------------+
+----------+----------+ |
| Get current screen | |
| index | |
+----------+----------+ |
| |
+----------+----------+ |
| Branch to each | |
| screen's procedure | |
+----------+----------+ |
| |
+---------------+-------+----------------+--... |
| | | |
+----------+----------+ +----------+----------+ +---+---+ |
| Read CNC information| | Read numeric value | |.... | |
| and display them on | | from MDI key and | | | |
| screen | | update data | | | |
+----------+----------+ +----------+----------+ +---+---+ |
| | | |
+---------------+-------+----------------+--... |
| |
+-----------------------------------+
2.4 The hardwares of CNC which are used in C Executor
SRAM DISK MAX 63/255KB(with SRAM 256KB) Sum of SRAM disk and
non-volatile variables
NON-VOLATILE MAX 63/255KB(with SRAM 256KB) is up to
VARIABLES (SRAM capacity - 1KB).
------------------------------------------------------------------------
MEMORY CARD PCMCIA or JEIDA compatible Other cards than
SRAM cards 256KB - 2MB specified card aren't
ATA Flash memory card supported
Supporting MS-DOS format
------------------------------------------------------------------------
F-ROM Available to store arbitrary Data size to store is
data variable according to
Application program can read F-ROM capacity, etc.
stored data (Max: about 6MB)
------------------------------------------------------------------------
MDI KEY ONG keyboard Key arrangement is
or QWERTY keyboard custmizable.
------------------------------------------------------------------------
TOUCH-PANEL 640x480 resolution "TOUCH-PANEL" option
Reading status and position is required.
------------------------------------------------------------------------
ITEM SPECIFICATION REMARKS
========================================================================
DISPLAY DEVICE 10.4-inch color LCD (*2)
10.4-inch color LCD with
touch-panel (*2)
- Alphanumeric character
(80x25(*3))
- Kanji character
(40x25(*3))
- 16-grayscale, reverse,
blink, background color,
for each character
------------------------------------------------------------------------
PRINTABLE - Alphanumeric and Kana
CHARACTER (ANK character)
- FANUC Kanji character
(about 2,400 characters
of JIS 1ST LEVEL)
- Special signs
- User definition character
(MAX 256 characters (half))
- JIS Kanji character
(1st and 2nd level, about
6,800 characters)
(*) You can use not only SRAM card but also ATA flash memory card as the
memory card for the development system.
+---------------+ --+
| SPECIFICATION | |
| DESIGN | |
+-------+-------+ |
| |
+-------+-------+ |
| FUNCTION | |
| DESIGN | |
+-------+-------+ |
| |
+-------+-------+ |
| PROGRAMIMIG | |
| CODING, | +-- working on PC
| EDITING | |
+-------+-------+ |
| |
+-------+-------+ |
| COMPILING, | |
| LINKING | |
+-------+-------+ |
| |
+-------+-------+ | --+
| DEBUGGING | | |
+-------+-------+ --+ |
| +-- working on CNC
+-------+-------+ |
| TESTING | |
+---------------+ ------+
You develop program just like as ordinary PC's program. In this step, some
parts of application program which can work on PC are developed. However,
only library functions which are provided by C Executor can be used in
application program. Some extended functions by compiler maker may not be
used on C Executor. Also hardware depending program such as BIOS call is not
available on C Executor.
(2) Testing on PC
After module level testing on PC, you develop entire application with
FANUC library. If any error occured in this step, you confirm usage of C
language library. You use makefile which is provided from FANUC to compile,
link and make memory card file.
You write application program to flash ROM on CNC via memory card.
(1) Diagnostics
assert
setjmp longjmp
The following MS-C graphic functions are provided. However, some detail
specifications of functions may be different between PC and CNC because both
hardwares are not compatible completely.
NAME FUCNTION
--------------------------------------------------------------------------
gr_displaychar Draw a standard size character
gr_displayfourlarge Draw a quad size character
gr_displaysixlarge Draw a hex size character
_putpattern Put monochrome image data
_getpattern Get monochrome image data
gr_dispstr Draw a standard size string
gr_disp6str Draw a hex size strings
gr_bitblt Copy image data
gr_disp4str Draw a quad size string.
gr_displaysmlchar Draw a small size character.
gr_dispsstr Draw a small size string.
gr_displayfchar Draw a FANUC character.
gr_dispfstr Draw a FANUC character string.
gr_disp9ifchar Draw 9-inch font character.
gr_disp9ifstr Draw 9-inch font character string.
mmc_line_b Draw a line between specified two points.
mmc_polyline Draw a polyline.
mmc_circle_b Draw a circle.
mmc_ellipse_b Draw an ellipse.
mmc_pie_b Draw a pie figure.
mmc_arc_b Draw an arc.
mmc_gettext Get character in the specified area.
mmc_puttext Put character data on memory to text screen.
mmc_textsize Get required byte size for getting character.
4.4 CNC/PMC window library
The following functions which are used to input/output data between CNC
/PMC are provided.
NAME FUNCTION
--------------------------------------------------------------------------
pmc_rdpmcrng Read arbitrary PMC data (range specified)
pmc_wrpmcrng Write arbitrary PMC data (range specified)
pmc_rdpcmsg Read PMC message
4.5 Other libraries
These funcitons are used to control key input from CNC's MDI panel.
NAME FUNCTION
--------------------------------------------------------------------------
aux_mdi_getmatrix Get MDI key matrix
aux_mdi_putmatrix Put MDI key matrix
aux_mdi_rstmatrix Reset MDI key matrix
aux_mdi_altmatrix Alter MDI key matrix
aux_mdi_putc Put one character to key input buffer
aux_mdi_write Write block data to key input buffer
aux_mdi_control Test or control key input buffer
aux_mdi_repeat Set key repeating interval time
aux_mdi_getstat Read inputting status of MDI key.
aux_mdi_clrbuf Clear input buffer of MDI key.
These functions are used to control CRT display and multiple window
display.
NAME FUNCTION
--------------------------------------------------------------------------
crt_getcurscrn Get current screen index
crt_setuserscrn Register user screen index
crt_isnewscrn Test screen switching status
crt_gettype Set CRT information
crt_setmode Set CRT screen mode
crt_cncscrn Switch to CNC screen
crt_fchar Outpout character by FANUC character code
crt_setuserskey Customize softkey on CNC screen
crt_setswt Set switching method between CNC's screen and user's
crt_setscrlarea Set scroll area
crt_opengr Open graphic display
crt_closegr Close graphic display
crt_graphic Enable or disable graphic display
crt_readfkey Read the status of function keys
crt_2ndcursor Display the secondary cursor
crt_settextattr Set attribute of characters on VRAM
crt_gettextattr Get attribute of character on VRAM
crt_setpalette Set color palette of VGA characters
crt_setallpalette Set all color palette of VGA characters
NAME FUNCTION
--------------------------------------------------------------------------
crt_getcncpalette Get color palette of CNC screen
crt_fstr Output character string by FANUC character code.
crt_gettextimg Get text data from VRAM.
crt_puttextimg Put text data into VRAM.
crt_setgraphpage Select graphics page to use.
crt_set6chmode Select drawing method of 6x sized character.
crt_setgsvmode Select saving method of graphic contents.
win_open Open window
win_close Close window
win_select Select window
win_activate Activate window
win_move Move window
win_size Alter window size
win_full Let active window be full screen size
win_window Let active window be window size
win_info Set window information
win_col Set color of window frame and title string
win_hide Hide window
win_show Show window
win_setttl Set window title string
win_setfrm Set window frame line character
win_getstat Get window display status
win_redraw Redraw windows.
crt_reguserchar Register user character
crt_mapuch Map user character
crt_getcgpttn Get CG pattern
vwin_open Open VGA window
vwin_close Close VGA window
vwin_select Select VGA window
vwin_show Show VGA window
vwin_hide Hide VGA window
vwin_info Get VGA window information
NAME FUNCTION
--------------------------------------------------------------------------
aux_file_format Format specified drive
aux_file_mount Mount memory card
aux_file_unmount Unmount memory card
aux_file_memcinfo Get memory card information
(4) Serial communication library
NAME FUNCTION
--------------------------------------------------------------------------
rs_open Initialize communication device
rs_close Terminate communication
rs_putc Put one character to communication buffer
rs_getc Get one character from communication buffer
rs_write Write block data to communication buffer
rs_read Read block data from communication buffer
rs_buffer Test or control communication buffer
rs_status Get status of communication line and buffer
rs_wait Wait communication event
NAME FUNCTION
--------------------------------------------------------------------------
os_show_tim Read timer
os_set_tim Set timer
os_sync_tim Wait until specified time
os_wait_tim Wait until specified term
os_make_flg Make event flag
os_delt_flg Delete event flag
os_sign_flg Signal event flag
os_wait_flg Wait event flag signal
os_clar_flg Clear event flag
os_puls_flg Signal event flag (pulse type)
os_make_sem Make counter-type semaphore
os_delt_sem Delete semaphore
os_sign_sem Signal semaphore
os_wait_sem Wait swmaphore signal
os_strt_wtsk Start window task
(6) FCA library
These are the functions which communicate with FCA (FANUC CASSETTE ADAPTOR)
or FANUC Handy File.
NAME FUNCTION
--------------------------------------------------------------------------
fca_setparam Initialize communication line
fca_bye Close communication line
fca_open Open a binary file on FCA device
fca_close Close a binary file
fca_read Read binary data from the file
fca_write Write binary data to the file
fca_fopen Open a text file on FCA device
fca_fclose Close a text device
fca_getc Read a character from the text file
fca_putc Write a character to the text file
fca_delete Delete a file on FCA device
fca_rename Change name of a file on FCA device
fca_readdir Read directory information of FCA device
fca_status Read status information of FCA device
fca_remains Read free space size of a floppy disk
These are the functions which read C Executor data stored in the flash ROM
module.
NAME FUNCTION
--------------------------------------------------------------------------
aux_from_open Open the specified F-ROM file
aux_from_close Close the F-ROM file
aux_from_select Select data in the F-ROM file
aux_from_moveptr Move read pointer
aux_from_read Read data from the F-ROM file
aux_from_getdir Read directory information of a F-ROM file
aux_from_getinfo Read F-ROM file information
aux_from_getc Read a character from the F-ROM file
aux_from_gets Read a line from the F-ROM file
This is the function which reads the status and (X,Y) coordinate of the
touch-panel.
NAME FUNCTION
--------------------------------------------------------------------------
aux_tpl_read Read the status and (X,Y) coordinate of touch-panel
II. PROGRAMMING
- This manual is intended to explain the C executor for the FANUC Series 30i.
- Do not use the manual for any purpose other than creation of applications
for the FS30i C executor.
- Some descriptions in the manual include JIS ruled lines and half-size
katakana characters. If your PC environment cannot display or print these
lines or characters correctly, convert them to appropriate character code.
- To display or print descriptions in the manual, set the tab step to "8".
- Most pages of the manual are in 80-column ( 60-line format. So they can
be printed normally on a typical printer.
- To display or print descriptions in the manual, use a fixed-pitch font
for both half-size (English) and full-size (Japanese) characters.
Microsoft, Windows, Windows NT, MS, and MS-DOS are Microsoft Corporation's
trademarks registered in the USA and other countries.
* The other corporate names and product names mentioned in the manual are
the trademarks or registered trademarks of the respective companies.
Description of CNC name, etc.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FS30i
In this document, the CNC names are described as the following abbreviated
names.
Abbreviation CNC
-----------------------+--------------------------------------------
FANUC Series 30i The generic name of all FS30i on which
or FS30i C Executor works.
Abbreviation Device
-----------------------+--------------------------------------------
14-inch CRT The generic name of the display devices
which have 10(+2) softkeys and 80-column x
25-line character screen (in standard mode).
For more information about display devices, see "3.6 CRT operation library".
0. INDEX
~~~~~~~~
Filename Contents
---------------+----------------------------------------------------
00index.man 0. INDEX
01soft.man 0.1 Required software for application development
4. Code Tables
41code.man 4.1 Keycode, Screen control code
42char.man 4.2 Displayable characters
(42char_j.man including Japanese KANJI characters)
5. Other References
51mtask.man 5.1 Multitasking
52fsys.man 5.2 File system
53pwon.man 5.3 Power-on procedure
54cncprm.man 5.4 Parameter setting on CNC
55d2m.man 5.5 Manual of dat2mem
56o8d.man 5.6 Adaptation for 8-digit program number
57wintsk.man 5.7 Window task
58cncscr.man 5.8 Conforming CNC screen display
59hilev.man 5.9 High-Level Task
5aprotec.man 5.10 Programming technique
(1) C Compiler.
(2) Linker.
Use the linker attached to the WindRiver Diab C/C++ Power-PC compiler.
-----------------------------------
Name CExe ANSI MS-C
-------------------+----+----+-----
assert M x x
-----------------------------------
----------------------------------- -----------------------------------
Name CExe ANSI MS-C Name CExe ANSI MS-C
-------------------+----+----+----- -------------------+----+----+-----
isalnum MAC x x ispunct MAC x x
isalpha MAC x x isspace MAC x x
iscntrl MAC x x isupper MAC x x
isdigit MAC x x isxdigit MAC x x
isgraph MAC x x tolower MAC x x
islower MAC x x toupper MAC x x
isprint MAC x x -----------------------------------
-----------------------------------
-----------------------------------
Name CExe ANSI MS-C
-------------------+----+----+-----
localeconv x x
setlocale x x
-----------------------------------
(4) Mathematics ( math.h )
----------------------------------- -----------------------------------
Name CExe ANSI MS-C Name CExe ANSI MS-C
-------------------+----+----+----- -------------------+----+----+-----
acos MAC x x frexp MAC x x
asin MAC x x ldexp MAC x x
atan MAC x x log MAC x x
atan2 MAC x x log10 MAC x x
cos MAC x x modf MAC x x
sin MAC x x pow MAC x x
tan MAC x x sqrt MAC x x
cosh MAC x x ceil MAC x x
sinh MAC x x fabs MAC x x
tanh MAC x x floor MAC x x
exp MAC x x fmod MAC x x
----------------------------------- -----------------------------------
-----------------------------------
Name CExe ANSI MS-C
-------------------+----+----+-----
setjmp MAC x x
longjmp MAC x x
-----------------------------------
-----------------------------------
Name CExe ANSI MS-C
-------------------+----+----+-----
signal x x
raise x x
-----------------------------------
-----------------------------------
Name CExe ANSI MS-C
-------------------+----+----+-----
va_start MAC x x
va_arg MAC x x
va_end MAC x x
-----------------------------------
(8) Input/output ( stdio.h )
----------------------------------- -----------------------------------
Name CExe ANSI MS-C Name CExe ANSI MS-C
-------------------+----+----+----- -------------------+----+----+-----
remove MAC x x fputc MAC x x
rename MAC x x fputs MAC x x
tmpfile x x getc M x x
tmpnam MAC x x getchar M x x
fclose MAC x x gets M x x
fflush MAC x x putc M x x
fopen MAC x x putchar M x x
freopen MAC x x puts M x x
setbuf MAC x x ungetc MAC x x
setvbuf MAC x x fread MAC x x
fprintf MAC x x fwrite MAC x x
fscanf MAC x x fgetpos MAC x x
printf M x x fseek MAC x x
scanf M x x fsetpos MAC x x
sprintf MAC x x ftell MAC x x
sscanf MAC x x rewind MAC x x
vfprintf MAC x x clearerr MAC x x
vprintf M x x feof MAC x x
vsprintf MAC x x ferror MAC x x
fgetc MAC x x perror M x x
fgets MAC x x -----------------------------------
-----------------------------------
----------------------------------- -----------------------------------
Name CExe ANSI MS-C Name CExe ANSI MS-C
-------------------+----+----+----- -------------------+----+----+-----
atof MAC x x exit x x
atoi MAC x x getenv x x
atol MAC x x system x x
strtod MAC x x bsearch MAC x x
strtol MAC x x qsort MAC x x
strtoul MAC x x abs MAC x x
rand MAC x x div MAC x x
srand MAC x x labs MAC x x
calloc MAC x x ldiv MAC x x
free MAC x x mblen x
malloc MAC x x mbtowc x
realloc MAC x x wctomb x
abort x x mbstowcs x
atexit x x wcstombs x
----------------------------------- -----------------------------------
(10) String handling ( string.h )
----------------------------------- -----------------------------------
Name CExe ANSI MS-C Name CExe ANSI MS-C
-------------------+----+----+----- -------------------+----+----+-----
memcpy MAC x x memchr MAC x x
memmove MAC x x strchr MAC x x
strcpy MAC x x strcspn MAC x x
strncpy MAC x x strpbrk MAC x x
strcat MAC x x strrchr MAC x x
strncat MAC x x strspn MAC x x
memcmp MAC x x strstr MAC x x
strcmp MAC x x strtok MAC x x
strcoll x x memset MAC x x
strncmp MAC x x strerror x x
strxfrm x x strlen MAC x x
----------------------------------- -----------------------------------
----------------------------------- -----------------------------------
Name CExe ANSI MS-C Name CExe ANSI MS-C
-------------------+----+----+----- -------------------+----+----+-----
clock MAC x x ctime MAC x x
difftime MAC x x gmtime MAC x x
mktime MAC x x localtime MAC x x
time MAC x x strftime x x
asctime MAC x x -----------------------------------
-----------------------------------
1.2 MS-C extended C standard library
----------------------------------- -----------------------------------
Name CExe ANSI MS-C Name CExe ANSI MS-C
-------------------+----+----+----- -------------------+----+----+-----
FP_OFF x _fheapset x
FP_SEG x _fheapwalk x
_atold x _fjstradv x
_bcalloc x _fjstrchr x
_beginthread x _fjstrcmp x
_bexpand x _fjstrcspn x
_bfree x _fjstricmp x
_bfreeseg x _fjstrlen x
_bheapadd x _fjstrlwr x
_bheapchk x _fjstrmatch x
_bheapmin x _fjstrncat x
_bheapseg x _fjstrncmp x
_bheapset x _fjstrncpy x
_bheapwalk x _fjstrnicmp x
_bios_xxxxxxx x _fjstrnset x
_bmalloc x _fjstrrchr x
_bmsize x _fjstrrev x
_brealloc x _fjstrset x
_cexit x _fjstrskip x
_c_exit x _fjstrspn x
_chain_intr x _fjstrstr x
_chdrive MAC x _fjstrtok x
_clear87 x _fjstrupr x
_control87 x _fmalloc MAC x
_disable x _fmemccpy x
_dos_xxxxxxxx x _fmemchr MAC x
_dos_findfirst MAC x _fmemcmp MAC x
_dos_findnext MAC x _fmemcpy MAC x
_dos_getdiskfree MAC x _fmemicmp MAC x
_enable x _fmemmove MAC x
_endthread x _fmemset MAC x
_exit x _fmsize MAC x
_expand MAC x _fmtob x
_fbtom x _fnthctype x
_fcalloc MAC x _fpreset x
_fexpand MAC x _frealloc MAC x
_ffree MAC x _freect x
_fheapchk x _fsopen x
_fheapmin x _fstrcat MAC x
----------------------------------- -----------------------------------
----------------------------------- -----------------------------------
Name CExe ANSI MS-C Name CExe ANSI MS-C
-------------------+----+----+----- -------------------+----+----+-----
_fstrchr MAC x _nmsize x
_fstrcmp MAC x _nrealloc x
_fstrcpy MAC x _nstrdup x
_fstrcspn MAC x _pclose x
_fstrdup x _pipe x
_fstricmp MAC x _popen x
_fstrlen MAC x _rotl MAC x
_fstrlwr MAC x _rotr MAC x
_fstrncat MAC x _searchenv x
_fstrncmp MAC x _spilitpath x
_fstrncpy MAC x _status87 x
_fstrnicmp MAC x _strdate x
_fstrnset MAC x _strerror x
_fstrpbrk MAC x _strtime x
_fstrrchr MAC x _strtold x
_fstrrev MAC x _tolower MAC x
_fstrset MAC x _toupper MAC x
_fstrspn MAC x _y0l x
_fstrstr MAC x _y1l x
_fstrtok MAC x _ynl x
_fstrupr MAC x access x
_fullpath x acosl x
_getdcwd x alloca MAC x
_getdrive MAC x asinl x
_harderr x atanl x
_hardresume x atan2l x
_hardretn x bdos x
_heapadd x btom MAC x
_heapchk x cabs MAC x
_heapmin x cabsl x
_heapset x ceill x
_heapwalk x cgets x
_j0l x chdir MAC x
_j1l x chkctype MAC x
_jnl x chmod x
_lrotl MAC x chsize x
_lrotr MAC x close MAC x
_makepath x coshl x
_matherrl x cosl x
_memavl x cprintf x
_memmax x cputs x
_msize MAC x creat MAC x
_ncalloc x cscanf x
_nexpand x cwait x
_nfree x dieeetomsbin x
_nheapchk x dmsbintoieee x
_nheapmin x dosexterr x
_nheapset x dup x
_nheapwalk x dup2 x
_nmalloc x ecvt MAC x
----------------------------------- -----------------------------------
----------------------------------- -----------------------------------
Name CExe ANSI MS-C Name CExe ANSI MS-C
-------------------+----+----+----- -------------------+----+----+-----
eof MAC x iskana MAC x
execl x iskanji MAC x
execle x iskanji2 MAC x
execlp x iskmoji MAC x
execlpe x iskpun MAC x
execv x ispnkana MAC x
execve x isprkana MAC x
execvp x itoa MAC x
execvpe x j0 x
expl x j1 x
fabsl x jisalpha MAC x
fcloseall x jisdigit MAC x
fcvt MAC x jishira MAC x
fdopen x jiskata MAC x
fgetchar x jiskigou MAC x
fieeetomsbin x jisl0 MAC x
filelength x jisl1 MAC x
fileno x jisl2 MAC x
floorl x jislower MAC x
flushall x jisprint MAC x
fmodl x jisspace MAC x
fmsbintoieee x jistojms MAC x
fputchar x jisupper MAC x
frexpl x jiszen MAC x
fstat x jmstojis MAC x
ftime x jn x
gcvt MAC x jstradv x
getch M x jstrchr x
getche x jstrcmp x
getcwd MAC x jstrcspn x
getpid x jstricmp x
getw x jstrlen x
halloc x jstrlwr x
hantozen MAC x jstrmatch x
hfree x jstrncat x
hypot MAC x jstrncmp x
hypotl x jstrncpy x
inp x jstrnicmp x
inpw x jstrnset x
int86 x jstrrchr x
int86x x jstrrev x
intdos x jstrset x
intdosx x jstrskip x
isalkana MAC x jstrspn x
isalnmkana MAC x jstrstr x
isascii MAC x jstrtok x
isatty x jstrupr x
iscsym x jtohira MAC x
iscsymf x jtokata MAC x
isgrkana MAC x jtolower MAC x
----------------------------------- -----------------------------------
----------------------------------- -----------------------------------
Name CExe ANSI MS-C Name CExe ANSI MS-C
-------------------+----+----+----- -------------------+----+----+-----
jtoupper MAC x spawnlpe x
kbhit M x spawnv x
ldexpl x spawnve x
lfind x spawnvp x
locking x spawnvpe x
logl x sqrtl x
log10l x stackavail MAC x
lsearch x stat x
lseek MAC x strcmpi MAC x
ltoa MAC x strdup x
matherr x stricmp MAC x
max x strlwr MAC x
memccpy x strnicmp MAC x
memicmp MAC x strnset MAC x
min x strrev MAC x
mkdir MAC x strset MAC x
mktemp x strupr MAC x
modfl x swab MAC x
movedata x tanl x
mtob MAC x tanhl x
nthctype MAC x tell MAC x
onexit (atexit) x tempnam x
open MAC x toascii MAC x
outp x tzset x
outpw x u_strtoldltoa x
powl x ultoa MAC x
putch x umask x
putenv x ungetch x
putw x unlink x
read MAC x utime x
rmdir MAC x wait x
rmtmp x write MAC x
segread x y0 x
setmode x y1 x
sinhl x yn x
sinl x zentohan MAC x
sopen x -----------------------------------
spawnl x
spawnle x
spawnlp x
-----------------------------------
1.3 Graphic library
---------------------------------------------------------------------------
Name CExe Function
---------------------+----+------------------------------------------------
_arc M Draw an arc or an elliptic arc.
_clearscreen M Clear screen.
_ellipse M Draw a circle or an ellipse.
_floodfill M Paint the closed region.
_getactivepage M Get the current active page number.
_getarcinfo M Get the information of the previous arc or pie.
_getbkcolor M Get the current back ground color.
_getcolor M Get the current fore ground color.
_getcurrentposition M Get the current position in the view coordinate.
_getfillmask M Get the current fill mask pattern.
_getfontinfo M Get the current font information.
_getgtextextent M Get the text extent by pixel unit.
_getgtextvector M Get the output vector of text.
_getimage M Get screen image.
_getkanji M Get the font pattern of Kanji character.
_getlinestyle M Get the current line style.
_getphyscoord M Convert view coordinate into physical.
_getpixel M Get color number the pixel.
_gettextposition M Get the current output position of text.
_gettextwindow M Get the text window border.
_getvideoconfig M Get the graphic configuration.
_getviewcoord M Convert physical coordinate into view.
_getvisualpage M Get the current visual page number.
_getwritemode M Get the current writing mode.
_grstatus M Get the return status of graphic function.
_imagesize M Get image buffer size.
_kanjisize M Get font pattern size of Kanji character.
_lineto M Draw a line.
_moveto M Move the current graphic output position.
_outgtext M Draw a text string using the current font.
_outmem M Draw a text string in a memory.
_outtext M Output a text string in the current position.
_pie M Draw a pie figure.
_polygon M Draw a polygon.
_putimage M Put image data on the screen.
_rectangle M Draw a rectangle.
_registerfonts M Register font file.
_remapallpalette M Map colors into all color palette.
_remappalette M Map a color into a color palette.
_setactivepage M Set the current active page number.
_setbkcolor M Set the current back ground color.
_setcliprgn M Set the clipping region.
_setcolor M Set the current fore ground color.
_setfillmask M Set the current fill mask pattern.
_setfont M Set the current font.
---------------------------------------------------------------------------
Name CExe Function
---------------------+----+------------------------------------------------
_setgtextvector M Set the current output vector of text.
_setlinestyle M Set the current line style.
_setpixel M Draw a pixel.
_settextposition M Set the current output position of text.
_settextrows M Set the text row number.
_settextwindow M Set the text window.
_setvideomode M Set the screen video mode.
_setvideomoderows M Set the screen video mode and text row number.
_setvieworg M Set the origin of the view port.
_setviewport M Set the clipping region and the view coordinate.
_setvisualpage M Set the current visual page number.
_setwritemode M Set the current writing mode.
_unregisterfonts M Delete registered font file.
_wrapon M Enable/disable line wrapping.
---------------------------------------------------------------------------
---------------------------------------------------------------------------
Name CExe Function
---------------------+----+------------------------------------------------
cnc_sysinfo MA Read CNC system information.
cnc_dwnstart MA Start output of NC program to be registered.
cnc_download MA Output NC program to be registered.
cnc_dwnend MA Stop output NC program to be registered.
cnc_vrfstart MA Start output NC program to be compared.
cnc_verify MA Output NC program to be compared.
cnc_vrfend MA Stop output NC program to be compared.
cnc_dncstart MA Start output NC program to be executed.
cnc_dnc MA Output NC program to be executed.
cnc_dncend MA Stop output NC program to be executed.
cnc_upstart MA Start input NC program.
cnc_upload MA Input NC program.
cnc_upend MA Stop input NC program.
cnc_search MA Search specified program.
cnc_delall MA Delete all programs.
cnc_delete MA Delete specified program.
cnc_rdprogdir MA Read program directory.
cnc_rdproginfo MA Read program information.
cnc_rdprgnum MA Read program number in executing.
cnc_rdseqnum MA Read sequence number in executing.
cnc_actf MA Read actual feed rate of controlled axes.
cnc_acts MA Read actual spindle speed.
cnc_absolute MA Read absolute position.
cnc_machine MA Read machine position.
cnc_relative MA Read relative position.
cnc_distance MA Read distance to go.
cnc_skip MA Read skipped position.
cnc_srvdelay MA Read servo delay amount.
cnc_accdecdly MA Read acceleration/deceleration delay amount.
cnc_rddynamic MA Read dynamic data.
cnc_statinfo MA Read CNC status information.
cnc_alarm MA Read alarm status.
cnc_rdalminfo MA Read alarm information.
cnc_rdtofs MA Read tool offset amount.
cnc_wrtofs MA Write tool offset amount.
cnc_rdtofsr MA Read tool offset amount (range specified).
cnc_wrtofsr MA Write tool offset amount (range specified).
cnc_rdzofs MA Read work origin offset.
cnc_wrzofs MA Write work origin offset.
cnc_rdzofsr MA Read work origin offset (range specified).
---------------------------------------------------------------------------
Name CExe Function
---------------------+----+------------------------------------------------
cnc_wrzofsr MA Write work origin offset (range specified).
cnc_rdparam MA Read parameter.
cnc_wrparam MA Write parameter.
cnc_rdparar MA Read parameters (range specified).
cnc_wrparas MA Write parameters (multiple output).
cnc_rdset MA Read setting parameter.
cnc_wrset MA Write setting parameter.
cnc_rdsetr MA Read setting parameters (range specified).
cnc_wrsets MA Write setting parameters (multiple output).
cnc_rdpitchr MA Read pitch error compensation data
(range specified).
cnc_wrpitchr MA Write pitch error compensation data
(range specified).
cnc_rdmacro MA Read custom macro variable.
cnc_wrmacro MA Write custom macro variable.
cnc_rdmacror MA Read custom macro variables (range specified).
cnc_wrmacror MA Write custom macro variables (range specified).
cnc_rdpmacro MA Read P-code macro variable.
cnc_wrpmacro MA Write P-code macro variable.
cnc_rdpmacror MA Read P-code macro variables (range specified).
cnc_wrpmacror MA Write P-code macro variables (range specified).
cnc_modal MA Read modal data.
cnc_diagnoss MA Read diagnostics data.
cnc_diagnosr MA Read diagnostics data (range specified).
cnc_adcnv MA Read A/D conversion data.
cnc_rdopmsg MA Read operator's message.
cnc_setpath MA Set path index (multi-path system).
cnc_getpath MA Get path index (multi-path system).
---------------------------------------------------------------------------
Name CExe Function
---------------------+----+------------------------------------------------
cnc_settime MA Set calendar timer of CNC.
cnc_rdspload MA Read load information of serial spindle.
cnc_rdexecprog MA Read executing program.
cnc_rdmovrlap MA Read manual handle override amount.
---------------------------------------------------------------------------
---------------------------------------------------------------------------
Name CExe Function
---------------------+----+------------------------------------------------
pmc_rdpmcrng MA Read arbitrary PMC data (range specified).
pmc_wrpmcrng MA Write arbitrary PMC data (range specified).
pmc_rdpcmsg MA Read PMC message.
---------------------------------------------------------------------------
1.5 Other libraries
These are the functions which customize key-input from MDI panel, alter
key code, enable key repeating and generate key code by the application
program.
---------------------------------------------------------------------------
Name CExe Function
---------------------+----+------------------------------------------------
aux_mdi_getmatrix MA Get MDI key matrix.
aux_mdi_putmatrix MA Put MDI key matrix.
aux_mdi_rstmatrix MA Reset MDI key matrix.
aux_mdi_altmatrix MA Alter MDI key matrix.
aux_mdi_putc MA Put one character to key input buffer.
aux_mdi_write MA Write block data to key input buffer.
aux_mdi_control MA Test or control key input buffer.
aux_mdi_repeat MA Set key repeating interval time.
aux_mdi_getstat MA Read inputting status of MDI key.
aux_mdi_clrbuf MA Clear input buffer of MDI key.
---------------------------------------------------------------------------
(2) CRT operation library
These are the functions which control CRT display and multiple window
display.
---------------------------------------------------------------------------
Name CExe Function
---------------------+----+------------------------------------------------
crt_getcurscrn MA Get current screen index.
crt_setuserscrn M Register user screen index.
crt_isnewscrn MA Test screen switching status.
crt_gettype MA Get CRT information.
crt_setmode MA Set CRT screen mode.
crt_cncscrn MA Switch to CNC screen.
crt_fchar M Output character by FANUC character code.
crt_setuserskey M Customize softkey on CNC screen.
crt_setswt MA Set switching method between CNC's screen and
user's.
crt_setscrlarea M Set scroll area.
crt_opengr M Open graphic display.
crt_closegr M Close graphic display.
crt_graphic MA Enable or disable graphic display.
crt_readfkey MA Read the status of function keys.
crt_2ndcursor M Display the secondary cursor.
crt_settextattr M Set attribute of characters on VRAM.
crt_gettextattr M Get attribute of character on VRAM.
crt_setpalette M Set color palette of VGA characters.
crt_setallpalette M Set all color palette of VGA characters.
crt_getcncpalette M Get color palette of CNC screen.
crt_fstr M Output character string by FANUC character code.
crt_gettextimg M Get text data from VRAM.
crt_puttextimg M Put text data into VRAM.
crt_setgraphpage M Select graphic page to use.
crt_set6chmode M Select drawing method of 6x sized character.
crt_setgsvmode M Select saving method of graphic contents.
win_open M Open window.
win_close M Close window.
win_select M Select window.
win_activate M Activate window.
win_move M Move window.
win_size M Alter window size.
win_full M Let active window be full screen size.
win_window M Let active window be window size.
win_info M Get window information.
win_col M Set color of window frame and title string.
win_hide M Hide window.
win_show M Show window.
win_setttl M Set window title string.
win_setfrm M Set window frame line character.
win_getstat M Get window display status.
win_redraw M Redraw windows.
crt_reguserchar M Register user character.
crt_mapuch M Map user character.
crt_getcgpttn M Get CG pattern.
vwin_open M Open VGA window.
vwin_close M Close VGA window.
vwin_select M Select VGA window.
---------------------------------------------------------------------------
Name CExe Function
---------------------+----+------------------------------------------------
vwin_show M Show VGA window.
vwin_hide M Hide VGA window.
vwin_info M Get VGA window information.
---------------------------------------------------------------------------
(3) File operation library
---------------------------------------------------------------------------
Name CExe Function
---------------------+----+------------------------------------------------
aux_file_format M Format specified drive.
aux_file_mount MAC Mount memory card.
aux_file_unmount MAC Unmount memory card.
aux_file_memcinfo MAC Get memory card information.
---------------------------------------------------------------------------
These are the functions which communicate with peripherals via reader/
puncher interface(RS-232C).
---------------------------------------------------------------------------
Name CExe Function
---------------------+----+------------------------------------------------
rs_open MAC Initialize communication device.
rs_close MAC Terminate communication.
rs_putc MAC Put one character to communication buffer.
rs_getc MAC Get one character from communication buffer.
rs_write MAC Write block data to communication buffer.
rs_read MAC Read block data from communication buffer.
rs_buffer MAC Test or control communication buffer.
rs_status MAC Get status of communication line and buffer.
rs_wait MAC Wait communication event.
---------------------------------------------------------------------------
(5) Task control library
---------------------------------------------------------------------------
Name CExe Function
---------------------+----+------------------------------------------------
os_show_tim MAC Read timer.
os_set_tim MAC Set timer.
os_sync_tim MAC Wait until specified time.
os_wait_tim MAC Wait until specified term.
os_make_flg MAC Make event flag.
os_delt_flg MAC Delete event flag.
os_sign_flg MAC Signal event flag.
os_wait_flg MAC Wait event flag signal.
os_clar_flg MAC Clear event flag.
os_puls_flg MAC Signal event flag. (pulse type)
os_make_sem MAC Make counter-type semaphore.
os_delt_sem MAC Delete semaphore.
os_sign_sem MAC Signal semaphore.
os_wait_sem MAC Wait semaphore signal.
os_strt_wtsk M Start window task.
---------------------------------------------------------------------------
These are the functions which communicate with FCA (FANUC CASSETTE ADAPTOR)
or FANUC Handy File.
---------------------------------------------------------------------------
Name CExe Function
---------------------+----+------------------------------------------------
fca_setparam MAC Initialize communication line.
fca_bye MAC Close communication line.
fca_open MAC Open a binary file on FCA device.
fca_close MAC Close a binary file.
fca_read MAC Read binary data from the file.
fca_write MAC Write binary data to the file.
fca_fopen MAC Open a text file on FCA device.
fca_fclose MAC Close a text device.
fca_getc MAC Read a character from the text file.
fca_putc MAC Write a character to the text file.
fca_delete MAC Delete a file on FCA device.
fca_rename MAC Change name of a file on FCA device.
fca_readdir MAC Read directory information of FCA device.
fca_status MAC Read status information of FCA device.
fca_remains MAC Read free space size of a floppy disk.
---------------------------------------------------------------------------
(7) F-ROM library
These are the functions which read C Executor data stored in the flash ROM
module.
---------------------------------------------------------------------------
Name CExe Function
---------------------+----+------------------------------------------------
aux_from_open MAC Open the specified F-ROM file.
aux_from_close MAC Close the F-ROM file.
aux_from_select MAC Select data in the F-ROM file.
aux_from_moveptr MAC Move read pointer.
aux_from_read MAC Read data from the F-ROM file.
aux_from_getdir MAC Read directory information of a F-ROM file.
aux_from_getinfo MAC Read F-ROM file information.
aux_from_getc MAC Read a character from the F-ROM file.
aux_from_gets MAC Read a line from the F-ROM file.
---------------------------------------------------------------------------
---------------------------------------------------------------------------
Name CExe Function
---------------------+----+------------------------------------------------
aux_tpl_read MAC Read the status and (X,Y) coordinate of the
touch-panel.
---------------------------------------------------------------------------
Japanese(Multi-byte character) functions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following functions are available on FS16i/18i C Executor, but not avail-
able on FS30i C Executor because of different system configurations and hard-
ware.
It is, however, possible to call these functions to create applications. This
is intended to maintain compatibility with applications developed for FS16.
With the FS30i, when these functions are called, they return a normal end
code without processing anything. The values they return are undefined.
When using these functions, be sure to bear what is described above in mind.
If you find any problem with your application in regard to the functions,
modify the application.
Table of contents
2.1 Outline
2.2 Special files
2.3 MAKEFILE
2.4 Installing the Diab C/C++ Power-PC compiler
2.5 Compatibility related to variables of type 'int'
2.6 Using compiler libraries
2.7 Describing 2-byte characters in source-codes
2.8 Remarks
2.1 Outline
In this documentation we assume that the "C Executor library disk" has been
installed in the directory C:\APP.
C:\> md c:\app\prog1
C:\> cd c:\app\prog1
C:\APP\PROG1> copy ..\tool\makefile
C:\APP\PROG1> copy ..\tool\version.c
(3) Editing the source files.
Make the source files ( *.c and *.h files ) of the application program in
the working directory. Use an arbitrary text editor to edit the files.
You may name the file as you like. Here, we assume that the following source
files are made.
#------------------------------------------------------------------------------
# Task definition block. Modify here for your application.
#------------------------------------------------------------------------------
TASK1 = <- list of the object filenames which constitute the Main
task.
TASK2 = <- list of the object filenames which constitute the
Communication task.
TASK3 = <- list of the object filenames which constitute the Alarm
task.
TASK4 = <- list of the object filenames which constitute the Window
task.
TASK5 = <- list of the object filenames which constitute the High-Level
task.
* The bottom of makefile
#------------------------------------------------------------------------------
# .O and .C dependency block.
#------------------------------------------------------------------------------
<- relationship of dependence between files.
#------------------------------------------------------------------------------
# End of .O and .C dependency block.
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# End of .O and .C dependency block.
#------------------------------------------------------------------------------
C:\APP\PROG1> nmake
When any compile error or link error occurs, modify the source file and
execute nmake again. The memory card file "cexec.mem", which will be stored
in the CNC unit, will be generated by completing execution of nmake.
Copy this file into the memory card, and write the application program into
F-ROM of the CNC unit according to the operating procedure of the CNC's
boot software.
2.2 Special files
#------------------------------------------------------------------------------
# Task definition block. Modify here for your application.
#------------------------------------------------------------------------------
TASK1 =
TASK2 =
TASK3 =
TASK4 =
TASK5 =
#------------------------------------------------------------------------------
# End of task definition block
#------------------------------------------------------------------------------
Define the macro TASK to specify the object files which compose the task.
For the single task application, you should only define the macro TASK1.
For the multi-task application, define the macro for all the tasks involved.
#------------------------------------------------------------------------------
# .O and .C dependency block.
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# End of .O and .C dependency block.
#------------------------------------------------------------------------------
The relations between the object file, the source file and the include file
are described here.
If S1.C includes ABC.H, and S2.C includes DEF.H, describe them as follows.
#------------------------------------------------------------------------------
# .O and .C dependency block.
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# End of .O and .C dependency block.
#------------------------------------------------------------------------------
2.4 Installing the Diab C/C++ Power-PC compiler
How to install the Diab C/C++ Power-PC compiler is described below by taking
its version 4.3f as an example. Refer to the applicable compiler reference
manual for detailed descriptions about individual items.
Inserting the Diab C/C++ Power-PC compiler CD into your PC automatically
starts the installer. If the installer fails to start, open the CD folder
and click SETUP.EXE in the folder to start it.
2) Installation Options
Check all the following check boxes.
- Install DIAB Compiler Suites
- Set Compiler Defaults
- Set Eval Key or License File Location
3) Tools Selection
Specify the type of the compiler you are going to install.
Check the C Compiler (D-CC) check box.
Do not use C++ Compiler, RTA Tools, FastJ Compiler, or Library Source.
4) Target Architectures
Select the following target system.
Target : PowerPC
Components : ELF (EABI)
8) File Selection
Specify a file to which you want to save the license key.
9) Select option for modify .bat file
Set up environment variables. Select the following:
"Let Setup modify the C:\Autoexec.bat file"
10) PowerPC
Select PPC603.
11) PPC603
Select "Hardware Floating Point."
12) ELF(EABI)
Select "cross."
Note) You may need to set up License Manager (FLEXlm License Manager)
depending on the license form. For details, ask the store from
which you bought your compiler.
For the compiler used with the FS30i C Executor, variables of type 'int' are
4-bytes long, while, for the compiler used with the FS16i/18i C Executor, they
are 2-bytes long. This difference in size may result in loss of compatibility.
The first part of some structures specified in CNC/PMC window functions con-
tains dummy variables of type 'int'. This does not impair compatibility when
the structures are used for data input/output. If a data area secured using,
for example, the malloc function is used for data input/output, however, the
data area may not function normally when its beginning part is offset based on
2-byte conversion.
Compatibility can be secured by a 'sizeof(int)' operator instead of 2-byte
conversion.
The following functions use the library supplied together with the compiler.
To use these functions, add the library to the LD.OPT file in the TOOL folder
in your development environment.
1) Functions that use the library supplied together with the compiler
setjmp, longjmp
va_start, va_arg, va_end
vprintf, vprintf, vsprintf
The Diab C/C++ Power-PC compiler does not support Japanese language. If a
2-byte character whose second byte happens to be 5Ch is included directly in a
source file, it is not recognized as correct data.
2.8 Remarks
C Executor uses the different include files from the compiler's default.
So, the object files made for the personal computer debugging cannot be used
for execution on CNC. Recompile using include files for C Executor. (The
include directory is switched by the macro CC in MAKEFILE)
[**WARNING**]
If an application program performs one of the following operations, the CNC
may behave in an unexpected manner.
- Access to data in an area other than the application data area.
- Execution of a program other than an application program (except call the
function that the C Executor offers it)
3. Function References
======================
[Example]
> ----------------------------------------------------------------------------
> 1. Format specified drive. <Main>
> ----------------------------------------------------------------------------
>
>
> [Name]
> aux_file_format
>
>
> [Syntax]
> #include <auxfile.h>
> int aux_file_format( unsigned char drive ) ;
>
>
> [Arguments]
> drive Drive name ( ='A' ).
>
>
> [Return]
> 0 Successfully.
> 9 Invalid drive name.
>
>
> [Description]
> Formats specified drive.
>
> Specify drive name to be formatted in "drive". For formatting S-RAM
> disk, execute as follows.
>
> aux_file_format( 'A' ) ;
>
> All files in specified drive will be deleted by execution of this
> function.
>
> Automatic initialization of S-RAM disk is done by setting CNC
> parameter No.8662, S-RAM capacity setting, and rebooting system.
"<Main>" after title shows that this function is available in the MAIN task,
not available in the Communication task and the Alarm task. If "<Main,Alarm,
Comm>" is in this section, this function is available in all tasks.
"[Name]" shows the name of this function.
"[Syntax]" shows required header files to use this function, type of return
value of this function and sequence and types of all arguments.
"[Arguments]" shows meanings of all arguments.
"[Return]" shows all possible return values and their types and meanings.
Lists of Functions
~~~~~~~~~~~~~~~~~~
1. Diagnostics ( assert.h )
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
1.1 assert Abort by assertion.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
2.1 isalnum Test for alphanumeric character.
2.2 isalpha Test for alphabetic character.
2.3 iscntrl Test for control character.
2.4 isdigit Test for numeric character.
2.5 isgraph Test for visible character.
2.6 islower Test for lowercase alphabetic character.
2.7 isprint Test for printable character.
2.8 ispunct Test for punctuation character.
2.9 isspace Test for whitespace character.
2.10 isupper Test for uppercase alphabetic character.
2.11 isxdigit Test for hexadecimal numeric character.
2.12 tolower Convert uppercase to lowercase.
2.13 toupper Convert lowercase to uppercase.
--------------------------------------------------------------------------
3. Mathematics ( math.h )
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
3.1 acos Calculate the arc cosine value.
3.2 asin Calculate the arc sine value.
3.3 atan Calculate the arc tangent value.
3.4 atan2 Calculate the arc tangent value.
3.5 ceil Calculate the smallest integer value.
3.6 cos Calculate the cosine value.
3.7 cosh Calculate the hyperbolic cosine value.
3.8 exp Calculate the exponential function.
3.9 fabs Calculate the absolute value.
3.10 floor Calculate the largest integer value.
3.11 fmod Calculate the floating point remainder value.
3.12 frexp Calculate the mantissa value.
3.13 ldexp Calculate the value multiplied by the power of 2.
3.14 log Calculate the natural (base-e) logarithm value.
3.15 log10 Calculate the base-10 logarithm value.
3.16 modf Get the fractional part and the integer part.
3.17 pow Calculate the raised value.
3.18 sin Calculate the sine value.
3.19 sinh Calculate the hyperbolic sine value.
3.20 sqrt Calculate the square root value.
3.21 tan Calculate the tangent value.
3.22 tanh Calculate the hyperbolic tangent value.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
4.1 setjmp Save current environment for non-local jump.
4.2 longjmp Execute a non-local jump.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
6.1 remove Delete a file.
6.2 rename Change the name of a file.
6.3 tmpnam Generate a temporary file name.
6.4 fclose Close a stream.
6.5 fflush Flush a stream buffer.
6.6 fopen Open a stream.
6.7 freopen Re-open a same stream.
6.8 setbuf Set a buffer for stream.
6.9 setvbuf Control a buffer for stream.
6.10 fprintf Print formatted data to a stream.
6.11 fscanf Read formatted data from a stream.
6.12 printf Print formatted data to standard output.
6.13 scanf Read formatted data from standard input.
6.14 sprintf Print formatted data to memory.
6.15 sscanf Read formatted data from memory.
6.16 vfprintf Print formatted data to a file using variable
arguments.
6.17 vprintf Print formatted data to standard output using
variable arguments.
6.18 vsprintf Print formatted data to memory using variable
arguments.
6.19 fgetc Read a character from a stream.
6.20 fgets Read a strings from a stream.
6.21 fputc Write a character to a stream.
6.22 fputs Write a string to a stream.
6.23 getc Read a character from a stream.
6.24 getchar Read a character from standard input.
6.25 gets Read a line string from standard input.
6.26 putc Write a character to a stream.
6.27 putchar Write a character to standard output.
6.28 puts Write a string to standard output.
6.29 ungetc Put a character into a steam.
6.30 fread Read data from a stream.
6.31 fwrite Write data to a stream.
6.32 fgetpos Get the current file position of a stream.
6.33 fseek Move the current file pointer.
6.34 fsetpos Set the current file position of stream.
6.35 ftell Get the current file pointer.
6.36 rewind Rewind the current file pointer to the top of file.
6.37 clearerr Reset error indicator of a stream.
6.38 feof Test for end-of-file.
6.39 ferror Test for error on stream.
6.40 perror Print error message.
--------------------------------------------------------------------------
7. General utilities ( stdlib.h )
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
7.1 atoi Convert string to int value.
7.2 atol Convert string to long value.
7.3 strtol Convert string to long value.
7.4 strtoul Convert string to unsigned long value.
7.5 rand Generate pseudo-random number.
7.6 srand Seed pseudo-random number generator.
7.7 calloc Allocate memory block initialized by 0.
7.8 free Free memory block.
7.9 malloc Allocate memory block.
7.10 realloc Reallocate memory block.
7.11 bsearch Perform binary search.
7.12 qsort Perform quick sort.
7.13 abs Get absolute value.
7.14 div Get quotient and remainder.
7.15 labs Get absolute value.
7.16 ldiv Get quotient and remainder.
7.17 atof Convert string to double value.
7.18 strtod Convert string to double value.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
8.1 memcpy Copy a memory block.
8.2 memmove Move a memory block.
8.3 strcpy Copy a string.
8.4 strncpy Copy a string.
8.5 strcat Concatenate a string.
8.6 strncat Concatenate a string.
8.7 memcmp Compare two memory blocks.
8.8 strcmp Compare two strings.
8.9 strncmp Compare two strings.
8.10 memchr Find a character in a memory block.
8.11 strchr Find a character in a string.
8.12 strcspn Get string length which doesn't include a character.
8.13 strpbrk Find a character position in a string.
8.14 strrchr Find the last character in a string.
8.15 strspn Get string length composed by specified character.
8.16 strstr Find a string in a string.
8.17 strtok Get a token.
8.18 memset Fill data in a memory block.
8.19 strlen Get string length.
--------------------------------------------------------------------------
9. Date and time ( time.h )
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
9.1 clock Get the current time.
9.2 mktime Convert local time to calender time.
9.3 time Get the current time.
9.4 asctime Convert time to string.
9.5 ctime Convert time to string.
9.6 gmtime Convert time to Greenwich mean time.
9.7 localtime Convert time to local time.
9.8 difftime Compute the difference between the two times.
--------------------------------------------------------------------------
Function Reference
~~~~~~~~~~~~~~~~~~
1. Diagnostics ( assert.h )
------------------------------------------------------------------------------
1.1 Abort by assertion. <Main>
------------------------------------------------------------------------------
[Name]
assert
[Syntax]
#include <assert.h>
void assert( int expression ) ;
[Arguments]
expression Expression to be diagnosed.
[Return]
------
[Description]
"assert" is used to debug programs simply. "assert" displays
diagnostic message and stops the program when the value of
"expression" is false (i.e. "0"). To stop the program, "while(1);"
is execute, the next step is never executed. When "expression" is
true (i.e. non-zero), "assert" does nothing.
"assert" is defined as MACRO, so, define NDEBUG identifier and
recompile to remove it.
------------------------------------------------------------------------------
2.1 Test for alphanumeric character. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
isalnum
[Syntax]
#include <ctype.h>
int isalnum( int c ) ;
[Arguments]
c Character code to be tested.
[Return]
Returns non-zero value if "c" is an alphanumeric character, otherwise
zero.
[Description]
"isalnum" tests whether "c" is an alphanumeric character ('A'-'Z',
'a'-'z','0'-'9') or not. This function works correctly for integer
value of ASCII character set. The result is not warranted for other
input value.
------------------------------------------------------------------------------
2.2 Test for alphabetic character. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
isalpha
[Syntax]
#include <ctype.h>
int isalpha( int c ) ;
[Arguments]
c Character code to be tested.
[Return]
Returns non-zero value if "c" is an alphabetic character, otherwise
zero.
[Description]
"isalpha" tests whether "c" is an alphabetic character ('A'-'Z',
'a'-'z') or not. This function works correctly for integer value of
ASCII character set. The result is not warranted for other input
value.
------------------------------------------------------------------------------
2.3 Test for control character. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
iscntrl
[Syntax]
#include <ctype.h>
int iscntrl( int c ) ;
[Arguments]
c Character code to be tested.
[Return]
Returns non-zero value if "c" is a control character, otherwise zero.
[Description]
"iscntrl" tests whether "c" is a control character (0x00-0x1f,0x7f)
or not. This function works correctly for integer value of ASCII
character set. The result is not warranted for other input value.
------------------------------------------------------------------------------
2.4 Test for numeric character. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
isdigit
[Syntax]
#include <ctype.h>
int isdigit( int c ) ;
[Arguments]
c Character code to be tested.
[Return]
Returns non-zero value if "c" is a numeric character, otherwise zero.
[Description]
"isdigit" tests whether "c" is a numeric character ('0'-'9')
or not. This function works correctly for integer value of ASCII
character set. The result is not warranted for other input value.
------------------------------------------------------------------------------
2.5 Test for visible character. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
isgraph
[Syntax]
#include <ctype.h>
int isgraph( int c ) ;
[Arguments]
c Character code to be tested.
[Return]
Returns non-zero value if "c" is a visible character, otherwise zero.
[Description]
"isgraph" tests whether "c" is a visible character (0x21-0x7e) or
not. This function works correctly for integer value of ASCII
character set. The result is not warranted for other input value.
------------------------------------------------------------------------------
2.6 Test for lowercase alphabetic character. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
islower
[Syntax]
#include <ctype.h>
int islower( int c ) ;
[Arguments]
c Character code to be tested.
[Return]
Returns non-zero value if "c" is a lowercase alphabetic character,
otherwise zero.
[Description]
"islower" tests whether "c" is a lowercase alphabetic character
('a'-'z') or not. This function works correctly for integer value of
ASCII character set. The result is not warranted for other input
value.
------------------------------------------------------------------------------
2.7 Test for printable character. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
isprint
[Syntax]
#include <ctype.h>
int isprint( int c ) ;
[Arguments]
c Character code to be tested.
[Return]
Returns non-zero value if "c" is a printable character, otherwise
zero.
[Description]
"isprint" tests whether "c" is a printable character (0x20-0x7e) or
not. This function works correctly for integer value of ASCII
character set. The result is not warranted for other input value.
------------------------------------------------------------------------------
2.8 Test for punctuation character. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
ispunct
[Syntax]
#include <ctype.h>
int ispunct( int c ) ;
[Arguments]
c Character code to be tested.
[Return]
Returns non-zero value if "c" is a punctuation character, otherwise
zero.
[Description]
"ispunct" tests whether "c" is a punctuation character (0x21-0x2f,
0x3a-0x40,0x5b-0x60,0x7b-0x7e) or not. This function works correctly
for integer value of ASCII character set. The result is not warranted
for other input value.
------------------------------------------------------------------------------
2.9 Test for whitespace character. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
isspace
[Syntax]
#include <ctype.h>
int isspace( int c ) ;
[Arguments]
c Character code to be tested.
[Return]
Returns non-zero value if "c" is a whitespace character, otherwise
zero.
[Description]
"isspace" tests whether "c" is a whitespace character (0x09-0x0d,
0x20) or not. This function works correctly for integer value of
ASCII character set. The result is not warranted for other input
value.
------------------------------------------------------------------------------
2.10 Test for uppercase alphabetic character. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
isupper
[Syntax]
#include <ctype.h>
int isupper( int c ) ;
[Arguments]
c Character code to be tested.
[Return]
Returns non-zero value if "c" is an uppercase alphabetic character,
otherwise zero.
[Description]
"isupper" tests whether "c" is an uppercase alphabetic character
('A'-'Z') or not. This function works correctly for integer value of
ASCII character set. The result is not warranted for other input
value.
------------------------------------------------------------------------------
2.11 Test for hexadecimal numeric character. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
isxdigit
[Syntax]
#include <ctype.h>
int isxdigit( int c ) ;
[Arguments]
c Character code to be tested.
[Return]
Returns non-zero value if "c" is a hexadecimal character, otherwise
zero.
[Description]
"isxdigit" tests whether "c" is a hexadecimal character ('A'-'Z',
'a'-'f','0'-'9') or not. This function works correctly for integer
value of ASCII character set. The result is not warranted for other
input value.
------------------------------------------------------------------------------
2.12 Convert uppercase to lowercase. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
tolower
[Syntax]
#include <ctype.h>
int tolower( int c ) ;
[Arguments]
c Character code to be converted.
[Return]
Returns a lowercase alphabetic character if "c" is an uppercase,
otherwise "c" as it is.
[Description]
"tolower" converts "c" to a lowercase alphabetic character if "c" is
uppercase.
------------------------------------------------------------------------------
2.13 Convert lowercase to uppercase. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
toupper
[Syntax]
#include <ctype.h>
int toupper( int c ) ;
[Arguments]
c Character code to be converted.
[Return]
Returns an uppercase alphabetic character if "c" is a lowercase,
otherwise "c" as it is.
[Description]
"toupper" converts "c" to an uppercase alphabetic character if "c" is
lowercase.
3. Mathematics ( math.h )
------------------------------------------------------------------------------
3.1 Calculate the arc cosine value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
acos
[Syntax]
#include <math.h>
double acos( double x ) ;
[Arguments]
x A floating point value to be calculated arc cosine.
[Return]
Returns the arc cosine value (in radian) of "x".
If argument is out of valid range, returns 0 and sets EDOM in the
global variable "errno".
[Description]
Calculates the arc cosine value of "x".
"x" must be in -1 through 1. The result is in 0 through PI radian.
------------------------------------------------------------------------------
3.2 Calculate the arc sine value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
asin
[Syntax]
#include <math.h>
double asin( double x ) ;
[Arguments]
x A floating point value to be calculated arc sine.
[Return]
Returns the arc sine value (in radian) of "x".
If argument is out of valid range, returns 0 and sets EDOM in the
global variable "errno".
[Description]
Calculates the arc sine value of "x".
"x" must be in -1 through 1. The result is in -PI/2 through PI/2
radian.
------------------------------------------------------------------------------
3.3 Calculate the arc tangent value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
atan
[Syntax]
#include <math.h>
double atan( double x ) ;
[Arguments]
x A floating point value to be calculated arc tangent.
[Return]
Returns the arc tangent value (in radian) of "x".
[Description]
Calculates the arc tangent value of "x".
The result is in -PI/2 through PI/2 radian.
------------------------------------------------------------------------------
3.4 Calculate the arc tangent value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
atan2
[Syntax]
#include <math.h>
double atan2( double y, double x ) ;
[Arguments]
x A denominator of the value to be calculated arc
tangent.
y A numerator of the value to be calculated arc tangent.
[Return]
Returns the arc tangent value (in radian) of y/x.
If both "y" and "x" are 0, returns 0 and sets EDOM in the global
variable "errno".
[Description]
Calculates the arc tangent value of y/x.
Both "x" and "y" are must not be 0. The result is in -PI through PI
radian.
------------------------------------------------------------------------------
3.5 Calculate the smallest integer value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
ceil
[Syntax]
#include <math.h>
double ceil( double x ) ;
[Arguments]
x A floating point value whose fractions is raised.
[Return]
Returns the smallest integer value that is greater than or equal to
"x".
[Description]
Calculates the smallest integer value that is greater than or equal
to "x".
------------------------------------------------------------------------------
3.6 Calculate the cosine value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
cos
[Syntax]
#include <math.h>
double cos( double x ) ;
[Arguments]
x A floating point value in radian to be calculated
cosine.
[Return]
Returns the cosine value of "x".
If "x" is too large, returns 0 and sets ERANGE in the global variable
"errno".
[Description]
Calculates the cosine value of "x".
------------------------------------------------------------------------------
3.7 Calculate the hyperbolic cosine value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
cosh
[Syntax]
#include <math.h>
double cosh( double x ) ;
[Arguments]
x A floating point value in radian to be calculated
hyperbolic cosine.
[Return]
Returns the hyperbolic cosine value of "x".
If the result is too large, returns +/-HUGE_VAL and sets ERANGE in
the global variable "errno".
[Description]
Calculates the hyperbolic cosine value of "x".
------------------------------------------------------------------------------
3.8 Calculate the exponential function. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
exp
[Syntax]
#include <math.h>
double exp( double x ) ;
[Arguments]
x A floating point value to be calculated exponential
function.
[Return]
Returns the exponential function value of "x".
If the result is too large, returns HUGE_VAL and sets ERANGE in the
global variable "errno". If the result is too small, returns 0.
[Description]
Calculates the exponential function ("e" raised to "x" power) of "x".
------------------------------------------------------------------------------
3.9 Calculate the absolute value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fabs
[Syntax]
#include <math.h>
double fabs( double x ) ;
[Arguments]
x A floating point value to be calculated the absolute
value.
[Return]
Returns the absolute value of "x".
[Description]
Calculates the absolute value of "x".
------------------------------------------------------------------------------
3.10 Calculate the largest integer value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
floor
[Syntax]
#include <math.h>
double floor( double x ) ;
[Arguments]
x A floating point value whose frantions is discarded.
[Return]
Returns the largest integet value that is less than or equal to "x"
[Description]
Calculates the largest integer value that is less than or equal to
"x".
------------------------------------------------------------------------------
3.11 Calculate the floating point remainder value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fmod
[Syntax]
#include <math.h>
double fmod( double x, double y ) ;
[Arguments]
x A divident to be calculated remainder.
y A divosor to be calculated remainder.
[Return]
Returns the remainder of "x" and "y". If "y" is 0, returns 0 and sets
EDOM in the global variable "errno".
[Description]
Calculates the remainder of "x" and "y". The remainder satisfies
"x - i*y ("i" is an integer value)" and its absolute value is smaller
than the absolute value of "y".
------------------------------------------------------------------------------
3.12 Calculate the mantissa value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
frexp
[Syntax]
#include <math.h>
double frexp( double value, int *exp ) ;
[Arguments]
value A floating point value to be divided.
exp A integer variable in where the exponential part is
stored.
[Return]
Returns the mantissa of a divided floating point value.
[Description]
Divides "value" into a mantissa part "m" and an exponential part "n"
"m" relates with "n" as "value = m * 2^n" and the absolute value of
"m" is greater than or equal to 0.5 and less than 1. If "value" is 0,
both "m" and "n" are 0.
------------------------------------------------------------------------------
3.13 Calculate the value multiplied by the power of 2. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
ldexp
[Syntax]
#include <math.h>
double ldexp( double x, int exp ) ;
[Arguments]
x A floating point value of the manttisa.
exp A exponential part.
[Return]
Returns the raied value.
If the result is too large, returns +/-HUGE_VAL and sets ERANGE in
the global variable "errno".
[Description]
Calculates the raised value "x * 2^exp" by the mantissa and the
exponent.
------------------------------------------------------------------------------
3.14 Calculate the natural (base-e) logarithm value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
log
[Syntax]
#include <math.h>
double log( double x ) ;
[Arguments]
x A floating point value to be calculated natural
logarithm.
[Return]
Returns the natural logarithm value of "x".
If "x" is 0, returns HUGE_VAL and sets ERANGE in the global variable
"errno". If "x" is negative, returns HUGE_VAL and sets EDOM in the
global variable "errno".
[Description]
Calculates the natural logarithm (base-e logarithm) value of "x".
------------------------------------------------------------------------------
3.15 Calculate the base-10 logarithm value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
log10
[Syntax]
#include <math.h>
double log10( double x ) ;
[Arguments]
x A floating point value to be calculated base-10
logarithm.
[Return]
Returns the base-10 logarithm value of "x".
If "x" is 0, returns HUGE_VAL and sets ERANGE in the global variable
"errno". If "x" is negative, returns HUGE_VAL and sets EDOM in the
global variable "errno".
[Description]
Calculates the base-10 logarithm value of "x".
------------------------------------------------------------------------------
3.16 Get the fractional part and the integer part. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
modf
[Syntax]
#include <math.h>
double modf( double value, double *iptr ) ;
[Arguments]
value A floating point value to be divided.
iptr A integer variable in where the integer part is
stored.
[Return]
Returns the fractional part of "value".
[Description]
Divides "value" into a fractional part and an integer part, both parts
have the same sign.
------------------------------------------------------------------------------
3.17 Calculate the raised value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
pow
[Syntax]
#include <math.h>
double pow( double x, double y ) ;
[Arguments]
x A floating point value to be raised.
y An exponent value.
[Return]
Returns "x" raised to the power of "y".
If "x" is 0 and "y" is negative, returns HUGE_VAL and sets EDOM in the
global variable "errno". If both "x" and "y" are 0 or "x" is negative
and "y" is not an integer, returns 0 and sets EDOM in the global
variable "errno". If the result is too large, returns +/-HUGE_VAL and
sets ERANGE in the global variable "errno".
[Description]
Calculates "x" raised to the power of "y".
------------------------------------------------------------------------------
3.18 Calculate the sine value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
sin
[Syntax]
#include <math.h>
double sin( double x ) ;
[Arguments]
x A floating point value in radian to be calculated
sine.
[Return]
Returns the sine value of "x".
If "x" is too large, returns 0 and sets ERANGE in the global variable
"errno".
[Description]
Calculates the sine value of "x".
------------------------------------------------------------------------------
3.19 Calculate the hyperbolic sine value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
sinh
[Syntax]
#include <math.h>
double sinh( double x ) ;
[Arguments]
x A floating point value in radian to be calculated
hyperbolic sine.
[Return]
Returns the hyperbolic sine value of "x".
If the result is too large, returns +/-HUGE_VAL and sets ERANGE in
the global variable "errno".
[Description]
Calculates the hyperbolic sine value of "x".
------------------------------------------------------------------------------
3.20 Calculate the square root value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
sqrt
[Syntax]
#include <math.h>
double sqrt( double x ) ;
[Arguments]
x A floating point value to be calculated square root.
[Return]
Returns the square root value of "x".
If "x" is negative, returns 0 and sets EDOM in the global variable
"errno".
[Description]
Calculates the square root value of "x".
------------------------------------------------------------------------------
3.21 Calculate the tangent value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
tan
[Syntax]
#include <math.h>
double tan( double x ) ;
[Arguments]
x A floating point value in radian to be calculated
tangent.
[Return]
Returns the tangent value of "x".
If "x" is too large, returns 0 and sets ERANGE in the global variable
"errno".
[Description]
Calculates the tangent value of "x".
------------------------------------------------------------------------------
3.22 Calculate the hyperbolic tangent value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
tanh
[Syntax]
#include <math.h>
double tanh( double x ) ;
[Arguments]
x A floating point value in radian to be calculated
hyperbolic tangent.
[Return]
Returns the hyperbolic tangent value of "x".
[Description]
Calculates the hyperbolic tangent value of "x".
4. Non-local jumps ( setjmp.h )
------------------------------------------------------------------------------
4.1 Save current environment for non-local jump. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
setjmp
[Syntax]
#include <setjmp.h>
int setjmp( jmp_buf env ) ;
[Arguments]
env Buffer in which contents of stack is saved.
[Return]
Returns zero. When "setjmp" is called again by "longjmp", it returns
"value", one of arguments of "longjmp". If "value" is zero, it
returns 1.
[Description]
"setjmp" saves contents of stack in "env" for restoring by the later
"longjmp". This enables jumping between functions.
See also "longjmp" for more information.
This function use the library supplied together with the compiler.
For details, see "How to make application program."
------------------------------------------------------------------------------
4.2 Execute a non-local jump. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
longjmp
[Syntax]
#include <setjmp.h>
void longjmp( jmp_buf env, int value ) ;
[Arguments]
env Buffer in which contents of stack is saved.
value Return value of "setjmp".
[Return]
------
[Description]
"longjmp" restores environment which has been saved by "setjmp"
before, and jumps to the previous "setjmp" function. This enables
jumping between functions. When "setjmp" is called from "longjmp",
"setjmp" returns "value" which is an one of arguments of "longjmp".
If "value" is zero, "setjmp" returns 1. After re-calling "setjmp",
values of all variables are ones at calling "longjmp". Global
variables whish has been changed by the other functions are not
restored. All register variables are undefined. Usually, "setjmp" is
called in the function which calls a function in which "longjmp" is
called. That is, "setjmp" must be the outer nested function than
"longjmp". When "longjmp" jumps to an inner function, the program
doesn't work correctly.
This function use the library supplied together with the compiler.
For details, see "How to make application program."
5. Variable arguments ( stdarg.h )
------------------------------------------------------------------------------
5.1 Initialize arg_ptr. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
va_start
[Syntax]
#include <stdarg.h>
void va_start( va_list arg_ptr, prev_param ) ;
[Arguments]
arg_ptr Pointer to the list of arguments.
prev_param Previous argument to the first optional argument.
[Return]
------
[Description]
Initialize "arg_ptr" to let it point the first argument of the
arguments list. This function is defined as MACRO. There are two
definitions of this macro, such as ANSI standard macro defined in
stdarg.h and UNIX System V macro defined in varargs.h. Only the ANSI
standard macro is defined in C library.
This function use the library supplied together with the compiler.
For details, see "How to make application program."
------------------------------------------------------------------------------
5.2 Get a next argument. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
va_arg
[Syntax]
#include <stdarg.h>
type va_arg( va_list arg_ptr, type ) ;
[Arguments]
arg_ptr Pointer to the list of arguments.
type Type of an argument to be gotten.
[Return]
Returns an argument pointed by "arg_ptr".
[Description]
Returns a value whose type is "type" in a position pointed by
"arg_ptr", then increments "arg_ptr" to let it point the next
argument in the list. The next argument position is determined by
size of "type". More arguments can be gotten using "arg_ptr"
repeatedly.
This function use the library supplied together with the compiler.
For details, see "How to make application program."
------------------------------------------------------------------------------
5.3 Reset arg_ptr. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
va_end
[Syntax]
#include <stdarg.h>
void va_end( va_list arg_ptr ) ;
[Arguments]
arg_ptr Pointer to the list of arguments.
[Return]
------
[Description]
Initializes "arg_ptr" as NULL.
This function use the library supplied together with the compiler.
For details, see "How to make application program."
6. Input/output ( stdio.h )
------------------------------------------------------------------------------
6.1 Delete a file. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
remove
[Syntax]
#include <stdio.h>
int remove( const char *path ) ;
[Arguments]
path Pathname of a file to be deleted.
[Return]
Returns zero if a file has been successfully deleted. If not, returns
-1 and sets an one of following values in the global variable "errno".
Symbol Meaning
---------------+-----------------------------------------------------
EACCES Specified file is a Read-Only file.
ENOENT Specified file or path does not exist, or "path" is
a directory.
[Description]
Deletes a file specified by "path".
------------------------------------------------------------------------------
6.2 Change the name of a file. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
rename
[Syntax]
#include <stdio.h>
int rename( const char *oldname, const char *newname ) ;
[Arguments]
oldname Pointer to the old name.
newname Pointer to the new name.
[Return]
Returns zero if file name has been successfully changed. If not,
returns -1 and sets an one of following values in the global variable
"errno".
Symbol Meaning
---------------+-----------------------------------------------------
EACCES A file or directory whose name is "newname" already
exists, "path" is invalid, or a different path is
specified in "newname" for a directory.
ENOENT Specified file or path does not exist.
EXDEV Attempted moving a file to the another device.
[Description]
Changes a file name or directory name specified by "oldname" to a
new name specified by "newname". The old name must be a path name
of a file or a directory which already exists. The new name must not
be a path name of a file or a directory which already exists. A file
can be moved from some directory to another one by specifying a
different path name in "oldname" from "newname". But it is impossible
to move a file from some device to the another device. For directory,
only renaming is available, moving is not available.
(Note) The library of the current version can not move any file. rename()
function calling to move a file makes an error. (errno=EACCES)
------------------------------------------------------------------------------
6.3 Generate a temporary file name. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
tmpnam
[Syntax]
#include <stdio.h>
char *tmpnam( char *string ) ;
[Arguments]
string Pointer to a temporary file name.
[Return]
Returns a pointer to a generated unique file name if it has been
successfully generated. If not, returns NULL.
[Description]
Generates a file name by which a temporary file can be opened without
overwriting existing files. This name is stored in a buffer pointed by
"string". If "strings" is NULL, the result is stored in the internal
static buffer. So, the following calling destroy this result. At
least buffer size must be larger than L-tmpnam bytes (defined in
stdio.h). This function can generate up to TMP_MAX of unique file
names. The generated string is composed of a path prefix, such as
P_tmpdir define in stdio.h, and following sequence of numeric
characters. The values of this numeric string are 1 through 65535.
A process of "tmpnam" is not changed by modifying L_tmpnam or
P_tmpdir.
------------------------------------------------------------------------------
6.4 Close a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fclose
[Syntax]
#include <stdio.h>
int fclose( FILE *stream ) ;
[Arguments]
stream Pointer to a FILE structure.
[Return]
Returns zero if a stream has been successfully closed. If not,
returns EOF.
[Description]
Closes specified stream. Buffers linked to the stream will be flushed
before closing. Buffers allocated by the system will be deallocated.
But buffers which has been allocated by user using "setbuf" or
"setvbuf" will not be deallocated automatically.
------------------------------------------------------------------------------
6.5 Flush a stream buffer. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fflush
[Syntax]
#include <stdio.h>
int fflush( FILE *stream ) ;
[Arguments]
stream Pointer to a FILE structure.
[Return]
Returns zero if a buffer has been successfully flushed. Also if
specified stream has no buffer, or it has been opened with Read-Only
mode, returns zero. If any error occurs, returns EOF. In this case,
any data may be missed because of incorrect writing.
[Description]
Flushes specified stream. If specified stream has been opened for
output, contents of the buffer are written to the file. If for input,
they are cleard. All streams for output are flushed by specifying
NULL in argument. Steams will still exist as they are after calling
"fflush". Calling "fflush" makes the result of "ungetc" ineffective.
Buffers are automatically flushed when a buffer is full, a stream is
closed, or program successfully terminated without closing streams.
This function does not influence to the streams without buffering.
------------------------------------------------------------------------------
6.6 Open a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fopen
[Syntax]
#include <stdio.h>
FILE *fopen( const char *filename, const char *mode ) ;
[Arguments]
filename Path name of a file.
mode Permitted access type.
[Return]
Returns a pointer to the opened file. If any error, returns NULL
pointer.
[Description]
Opens a file specified by "filename". Specify access type which is
requested to the file in "mode".
Type Meaning
-----------+-----------------------------------------------------
r Opens with Read-Only mode. Error if specified file
does not exist.
w Opens with output mode. Opens an empty file. Contents
of the existing file are destroyed.
a Opens with output mode, appending to the end of the
file. If specified file does not exist, creates it.
r+ Opens with both input and output mode. Specified file
must exist.
w+ Opens an empty file with both input and output mode.
Contents of the existing file are destroyed.
a+ Opens with both input and output. If no specified
file, creates it.
Mode Meaning
-----------+-----------------------------------------------------
t Opens the file in text mode.(default)
In this mode, line feed characters are converted
as follows.
Input CR+LF --> LF
Output LF --> CR+LF
b Opens the file in binary mode.
In this mode, line feed characters are not converted.
------------------------------------------------------------------------------
6.7 Re-open a same stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
freopen
[Syntax]
#include <stdio.h>
FILE *freopen( const char *filename, const char *mode,
FILE *stream ) ;
[Arguments]
filename Path name of a new file.
mode Permitted access type.
stream Pointer to a FILE structure.
[Return]
Returns a pointer to the newly opened file. If any error, closes a
old file and returns NULL pointer.
[Description]
Closes a file linked to the stream, then reallocates the stream to
the file specified by "filename". This function is usually used to
redirect already opened standard input (stdin), standard output
(stdout) or standard error output (stderr) to specified file. The
new file to be linked the steam is opened with "mode". Specify access
type which is requested to the file in "mode".
Type Meaning
-----------+-----------------------------------------------------
r Opens with Read-Only mode. Error if specified file
does not exist.
w Opens with output mode. Opens an empty file. Contents
of the existing file are destroyed.
a Opens with output mode, appending to the end of the
file. If specified file does not exist, creates it.
r+ Opens with both input and output mode. Specified file
must exist.
w+ Opens an empty file with both input and output mode.
Contents of the existing file are destroyed.
a+ Opens with both input and output. If no specified
file, creates it.
Addtionally, the following open mode can also be specified as
additional character in the above list.
Mode Meaning
-----------+-----------------------------------------------------
t Opens the file in text mode.(default)
In this mode, line feed characters are converted
as follows.
Input CR+LF --> LF
Output LF --> CR+LF
b Opens the file in binary mode.
In this mode, line feed characters are not converted.
------------------------------------------------------------------------------
6.8 Set a buffer for stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
setbuf
[Syntax]
#include <stdio.h>
void setbuf( FILE *stream, char *buffer ) ;
[Arguments]
stream Pointer to a FILE structure.
buffer Buffer allocated by user.
[Return]
------
[Description]
Controls buffering of a stream. Specified stream must be already
opened file from/to which any input/output has not been done.
Buffering is not performed for the stream if "buffer" is NULL.
Otherwise, "buffer" must point a buffer whose size is BUFSIZ.
BUFSIZ is a buffer size defined in stdio.h. By calling this function,
user defined buffer is used as an input/output buffer instead of
system defined one. Functions of "setbuf" is included in "setvbuf".
It is recommended to use "setvbuf" for newly made programs. "setbuf"
is provided for compatibility with existing programs.
------------------------------------------------------------------------------
6.9 Control a buffer for stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
setvbuf
[Syntax]
#include <stdio.h>
int setvbuf( FILE *stream, char *buffer, int mode, size_t size ) ;
[Arguments]
stream Pointer to a FILE structure.
buffer Buffer allocated by user.
mode Buffering mode.
size Buffer size.
[Return]
Returns zero if successful. If not (invalid mode or buffer size),
returns non-zero.
[Description]
Controls buffering and buffer size of stream. Specified stream must
be already opened file from/to which any input/output has not been
done. Buffer pointed by "buffer" is used unless "buffer" is NULL.
If NULL, new buffer whose size is "size" is automatically allocated.
"mode" is one of follows.
Mode Meaning
---------------+-----------------------------------------------------
_IOFBF Full buffering.
"buffer" is a pointer to the buffer, and "size is a
size of the buffer. If "buffer" is NULL, new buffer
of "size" byte allocated automatically is used.
_IONBF No buffer is used regardless of "buffer" and "size".
------------------------------------------------------------------------------
6.10 Print formatted data to a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fprintf
[Syntax]
#include <stdio.h>
int fprintf( FILE *stream, const char *format [, argument]... ) ;
[Arguments]
stream Pointer to a FILE structure.
format Format control string.
argument Optional arguments.
[Return]
Returns number of characters which have been output. If any error,
returns negative value.
[Description]
Outputs a series of formatted data to a stream. Each arguments
(if exist) are output with conversion according to the format
specification in "format". Formats of "format" are same as ones of
"printf". See "printf" for details of "format" and "argument".
------------------------------------------------------------------------------
6.11 Read formatted data from a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fscanf
[Syntax]
#include <stdio.h>
int fscanf( FILE *stream, const char *format [, argument]... ) ;
[Arguments]
stream Pointer to a FILE structure.
format Format control string.
argument Optional arguments.
[Return]
Returns a number of fields converted successfully. This does not
includes fields which has been read and not converted. Returns EOF
if any error is detected in a stream before the first conversion,
or the end of file is detected. Return value zero means that no
fields have been converted.
[Description]
Reads formatted data to arguments (if exist) from a stream.
"argument" are pointer to variables whose types are same as type
specification in "format". Formats of "format" are same as "scanf".
See "scanf" for details of "format" and "argument".
------------------------------------------------------------------------------
6.12 Print formatted data to standard output. <Main>
------------------------------------------------------------------------------
[Name]
printf
[Syntax]
#include <stdio.h>
int printf( const char *format [, argument]... ) ;
[Arguments]
format Format control string.
argument Optional arguments.
[Return]
Returns number of characters which have been output. If any error,
returns negative value.
[Description]
Outputs a series of formatted data to the standard output stream
(stdout). "format" is composed of ordinary characters, escape
sequences and format specifications. Ordinary characters and escape
sequences are output to the standard output in order. If any
arguments follow the format string, output formatting for the
arguments are performed using the format string. The first character
of format specification is '%'. Format specification is decoded
rightward from the left. The first argument following "format" is
output according to the first format specification. The second
argument is output according to the second format specification, and
so forth. More arguments than the format specifications are ignored.
If a number of arguments is short of format specifications, the
result of "printf" is not warranted.
1) Format specification format.
3) "flag" specification
flag Meaning Default
-------+-------------------------------+---------------------------
- Left justification. Right justification.
+ Sign before a value. Only '-' for a negative
value.
0 Padding by '0' till the No padding.
minimum width.
SPACE Leading space to output value. No leading space.
# Prefix "0", "0x" or "0X" No prefix.
before non-'0' numeric
character for 'o','x' or 'X'
format.
Forced decimal point for 'e', Decimal point if needed.
'E' or 'f' format.
Forced decimal point and Decimal point if needed,
no-suppressing trailing '0' suppressing trailing '0'.
for 'g' or 'G' format.
------------------------------------------------------------------------------
6.13 Read formatted data from standard input. <Main>
------------------------------------------------------------------------------
[Name]
scanf
[Syntax]
#include <stdio.h>
int scanf( const char *format [, argument]... ) ;
[Arguments]
format Format control string.
argument Optional arguments.
[Return]
Returns a number of fields converted successfully. This may be less
than the requested number to "scanf". This does not includes fields
which has been read and not converted. Returns EOF if any error is
detected in a stream before the first conversion, or the end of file
is detected. Return value zero means that no fields have been
converted.
[Description]
Reads formatted data to arguments from the standard input stream
(stdin). "argument" are pointer to variables whose types are same as
type specification in "format". Format specification controls
decoding input fields. Specify one or more of following characters
for format specification.
[Name]
sprintf
[Syntax]
#include <stdio.h>
int sprintf( char *buffer, const char *format [, argument]... ) ;
[Arguments]
buffer Buffer in which string is stored.
format Format control string.
argument Optional arguments.
[Return]
Returns number of characters which have been stored in the buffer.
(The last null character is not counted.)
[Description]
Stores a series of formatted data in a buffer. Each arguments (if
exist) are stored with conversion according to the format
specification in "format". Formats of "format" are same as ones of
"printf". See "printf" for details of "format" and "argument".
------------------------------------------------------------------------------
6.15 Read formatted data from memory. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
sscanf
[Syntax]
#include <stdio.h>
int sscanf( const char *buffer, const char *format
[, argument]... ) ;
[Arguments]
buffer Stored data.
format Format control string.
argument Optional arguments.
[Return]
Returns a number of fields converted successfully. This does not
includes fields which has been read and not converted. Returns EOF
if the end of string is detected. Return value zero means that no
fields have been converted.
[Description]
Reads formatted data to arguments (if exist) from a buffer.
"argument" are pointer to variables whose types are same as type
specification in "format". Formats of "format" are same as "scanf".
See "scanf" for details of "format" and "argument".
------------------------------------------------------------------------------
6.16 Print formatted data to a file using variable arguments.
<Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
vfprintf
[Syntax]
#include <stdio.h>
#include <stdarg.h>
int vfprintf( FILE *stream, const char *format, va_list argptr ) ;
[Arguments]
stream Pointer to a FILE structure.
format Format control string.
argptr Pointer to a list of arguments.
[Return]
Returns number of characters which have been output. If any error,
returns negative value.
[Description]
Outputs a series of formatted data to a stream. Each arguments are
output with conversion according to the format specification in
"format". "argptr" is a pointer of va_list type defined in stdarg.h.
It points a list of arguments to be converted and output according to
format specifications of "format". Formats of "format" are same as
ones of "printf". See "printf" for details of "format" and
"argument".
This function use the library supplied together with the compiler.
For details, see "How to make application program."
------------------------------------------------------------------------------
6.17 Print formatted data to standard output using variable arguments. <Main>
------------------------------------------------------------------------------
[Name]
vprintf
[Syntax]
#include <stdio.h>
#include <stdarg.h>
int vprintf( const char *format, va_list argptr ) ;
[Arguments]
format Format control string.
argptr Pointer to a list of arguments.
[Return]
Returns number of characters which have been output. (The last null
character is not counted.) If any error, returns negative value.
[Description]
Outputs a series of formatted data to the standard output. Each
arguments are output with conversion according to the format
specification in "format". "argptr" is a pointer of va_list type
defined in stdarg.h. It points a list of arguments to be converted
and output according to format specifications of "format".
Formats of "format" are same as ones of "printf". See "printf" for
details of "format" and "argument".
This function use the library supplied together with the compiler.
For details, see "How to make application program."
------------------------------------------------------------------------------
6.18 Print formatted data to memory using variable arguments.
<Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
vsprintf
[Syntax]
#include <stdio.h>
#include <stdarg.h>
int vsprintf( char *buffer, const char *format, va_list argptr ) ;
[Arguments]
buffer Buffer in which string is stored.
format Format control string.
argptr Pointer to a list of arguments.
[Return]
Returns number of characters which have been stored. (The last null
character is not counted.) If any error, returns negative value.
[Description]
Stores a series of formatted data in a buffer pointed "buffer". Each
arguments are stored with conversion according to the format
specification in "format". "argptr" is a pointer of va_list type
defined in stdarg.h. It points a list of arguments to be converted
and output according to format specifications of "format". Formats
of "format" are same as ones of "printf". See "printf" for details
of "format" and "argument".
This function use the library supplied together with the compiler.
For details, see "How to make application program."
------------------------------------------------------------------------------
6.19 Read a character from a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fgetc
[Syntax]
#include <stdio.h>
int fgetc( FILE *stream ) ;
[Arguments]
stream Pointer to a FILE structure.
[Return]
Returns a read character. Returns EOF if any error if any error or
the end of file is detected. Use "feof" and "ferror" functions to
distinguish an error from EOF.
[Description]
Reads a character from a file linked to "stream". A character is
returned with conversion to int. A file pointer is incremented to
point the next character. This function is same as "getc" function
and is not a macro but a function.
------------------------------------------------------------------------------
6.20 Read a strings from a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fgets
[Syntax]
#include <stdio.h>
char *fgets( char *string, int n, FILE *stream ) ;
[Arguments]
string Buffer in which data is stored.
n Buffer size.
stream Pointer to a FILE structure.
[Return]
Returns "string" if successful. Returns NULL if any error or the end
of file is detected. Use "feof" and "ferror" functions to distinguish
an error from EOF.
[Description]
Reads characters from a file linked to "stream" and stores them in
"string". Reading is repeated until newline character('\n') is
detected, the end of the stream is detected, or a length of read
character become equivalent to "n-1". The result is stored in
"string" adding null character('\0'). If "n" is 1, "string" is
empty (""). This function is similar to "gets" function, but "gets"
replaces a newline character to a null character.
------------------------------------------------------------------------------
6.21 Write a character to a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fputc
[Syntax]
#include <stdio.h>
int putc( int c, FILE *stream ) ;
[Arguments]
c Character to be written.
stream Pointer to a FILE structure.
[Return]
Returns a written character. If any error, returns EOF.
[Description]
Writes a character specified by "c" to an output stream. This function
is similar to "putc" function, buf this is a function, not a macro.
------------------------------------------------------------------------------
6.22 Write a string to a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fputs
[Syntax]
#include <stdio.h>
int fputs( const char *string, FILE *stream ) ;
[Arguments]
string String to be output.
stream Pointer to a FILE structure.
[Return]
Returns "non-negative value" if successful. If any error, returns
EOF.
[Description]
Write "strings" to a stream. The terminating character, null
character ('\0'), is not output.
------------------------------------------------------------------------------
6.23 Read a character from a stream. <Main>
------------------------------------------------------------------------------
[Name]
getc
[Syntax]
#include <stdio.h>
int getc( FILE *stream ) ;
[Arguments]
stream Current stream.
[Return]
Returns a read character. Returns EOF if any error or the end of file
is detected. Use "feof" and "ferror" functions to distinguish an error
from EOF.
[Description]
Reads a character from a file linked to "stream". A file pointer is
incremented to point the next character. This function is same as
"fgetc" function and is not a function but a macro.
------------------------------------------------------------------------------
6.24 Read a character from standard input. <Main>
------------------------------------------------------------------------------
[Name]
getchar
[Syntax]
#include <stdio.h>
int getchar( void ) ;
[Arguments]
------
[Return]
Returns a character read from the standard input. Returns EOF if
any error or the end of file is detected. Use "feof" and "ferror"
functions to distinguish an error from EOF.
[Description]
Reads a character from the standard input. This is same as "getc"
function. This function is same as "_fgetchar" function but is a
macro.
------------------------------------------------------------------------------
6.25 Read a line string from standard input. <Main>
------------------------------------------------------------------------------
[Name]
gets
[Syntax]
#include <stdio.h>
char *gets( char *buffer ) ;
[Arguments]
buffer Pointer to a buffer in which input characters are
stored.
[Return]
Returns address of a buffer specified in argument. Returns NULL if
any error or the end of file is detected. Use "feof" and "ferror"
functions to distinguish an error from EOF.
[Description]
Reads a line from the standard input stream (stdin) and stores it in
"buffer". A line is composed of all characters until the first
newline character('\n'). A newline character is replaced with a null
character('\0'). This function is similar to "fgets" function, buf
"fgets" doesn't replace a newline character.
------------------------------------------------------------------------------
6.26 Write a character to a stream. <Main>
------------------------------------------------------------------------------
[Name]
putc
[Syntax]
#include <stdio.h>
int putc( int c, FILE *stream ) ;
[Arguments]
c Character to be written.
stream Pointer to a FILE structure.
[Return]
Returns a written character. If any error, returns EOF.
[Description]
Writes a character "c" to an output stream. Any integer value
whatever can be specified, but the only lower 8 bits are written.
------------------------------------------------------------------------------
6.27 Write a character to standard output. <Main>
------------------------------------------------------------------------------
[Name]
putchar
[Syntax]
#include <stdio.h>
int putchar( int c ) ;
[Arguments]
c Character to be written.
[Return]
Returns a written character. If any error, returns EOF.
[Description]
Writes a character "c" to the standard output (stdout). This is same
as "putc( c, stdout )".
------------------------------------------------------------------------------
6.28 Write a string to standard output. <Main>
------------------------------------------------------------------------------
[Name]
puts
[Syntax]
#include <stdio.h>
int puts( const char *string ) ;
[Arguments]
string String to be written.
[Return]
Returns "non-positive value" if successful. If any error, returns
EOF.
[Description]
Writes "string" to the standard output (stdout). The last character
of the string, null character('\0'), is replaced with a newline
character('\n').
------------------------------------------------------------------------------
6.29 Put a character into a steam. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
ungetc
[Syntax]
#include <stdio.h>
int ungetc( int c, FILE *stream ) ;
[Arguments]
c Character to be pushed.
stream Pointer to a FILE structure.
[Return]
Returns a character "c" if successful. Returns EOF if nothing has
been read from the stream or the specified character has not be able
to pushed into the stream.
[Description]
Pushes a character "c" into the stream and clears the end of file
indicator. The stream must be opened with "Read mode". The next
reading from the stream is processed from "c". If "c" is EOF, it is
ignored. The pushed character into the stream will be cleared befer
it is read from the stream by calling "fflush", "fseek", "fsetpos"
or "rewind" functions. The file position indicator is not changed by
this function. If "ungetc" function is used for any text stream, the
file pointer is undefined until all pushed characters are read or
cleared. If "ungetc" function is used for any binary stream, the
file point indicator is set to the previous position. In the case
that the value of the file point indicator was zero before calling
this function, the value after calling is not warranted. When
"ungetc" function is calling twice continuously without any reading,
the result is unstable. After calling of "fscanf" function, "ungetc"
function will be unsuccessful unless one more reading procedure.
(Because "fscanf" function calls "ungetc" function itself.)
------------------------------------------------------------------------------
6.30 Read data from a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fread
[Syntax]
#include <stdio.h>
size_t fread( void *buffer, size_t size, size_t count,
FILE *stream ) ;
[Arguments]
buffer Pointer to a data buffer.
size Item size in byte.
count Maximum number of item to be read.
stream Pointer to a FILE structure.
[Return]
Returns number of items which has been read actually. If this value
is less than "count", any error or the end of file before reading
"count" times might be detected. If any error, the file pointer is
undefined. The value read partially is undefined. Use "feof" and
"ferror" functions to distinguish an error from EOF. If "size" or
"count" is zero, returns zero and doesn't change contents of buffer.
[Description]
Reads "count" elements of "size" bytes item from an input stream,
and stores into "buffer". The file pointer linked to "stream" (if
exists) is incremented by bytes number which has been read actually.
If the specified stream is opened with text mode, a pair of carriage
return and line feed (CR+LF) is replaced with a line feed character
(LF). This conversion doesn't affect the file pointer and the return
value.
------------------------------------------------------------------------------
6.31 Write data to a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fwrite
[Syntax]
#include <stdio.h>
size_t fwrite( void *buffer, size_t size, size_t count,
FILE *stream ) ;
[Arguments]
buffer Pointer to a data buffer.
size Item size in byte.
count Maximum number of item to be written.
stream Pointer to a FILE structure.
[Return]
Returns number of items which has been written actually. If this
value is less than "count", any error might be detected. If any
error, the file pointer is undefined.
[Description]
Writes "count" elements of "size" bytes item from "buffer" to a
output stream. The file pointer linked to "stream" (if exists) is
incremented by bytes number which has been written actually. If the
specified stream is opened with text mode, a line feed character(LF)
is replaced with a pair of carriage return and line feed (CR+LF).
This conversion doesn't affect the return value.
------------------------------------------------------------------------------
6.32 Get the current file position of a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fgetpos
[Syntax]
#include <stdio.h>
int fgetpos( FILE *stream, fpos_t *pos ) ;
[Arguments]
stream Pointer to a FILE structure.
pos Pointer to a position indicator to be stored.
[Return]
Returns zero if successful. If not, returns non-zero value and sets
an one of following values, which are defined in stdio.h, in a global
variable "errno".
Symbol Meaning
---------------+-----------------------------------------------------
EBADF File handle linked to the specified stream is
invalid, or cannot be accessed.
EINVAL Specified stream is invalid.
[Description]
Gets a file position indicator of the specified stream, and stores
it in the buffer pointed by "pos". It is able to restore the pointer
of the stream at calling "fgetpos" function by "fsetpos" function
using an information stored in "pos". Data format of "pos" is internal
one, it is used only by "fgetpos" and "fsetpos" functions.
------------------------------------------------------------------------------
6.33 Move the current file pointer. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fseek
[Syntax]
#include <stdio.h>
int fseek( FILE *streem, long offset, int orign ) ;
[Arguments]
stream Pointer to a FILE structure.
offset Offset from origin in byte.
orign Origin position.
[Return]
Returns zero if successful. If not, returns non-zero value. For non-
seekable devices, returns unstable value.
[Description]
Moves a file pointer (if exists) linked to the stream to "offset"
bytes position from "orign". The following operations to the stream
are performed at this new position. It is possible to both read and
write as the next operation to the streams which are opened with
updating mode. It is possible to move the pointer to any arbitrary
position, also beyond the end of file. Calling this function clears
the end of file indicator. "orign" is one of the following constants
which are defined in stdio.h.
Symbol Meaning
---------------+-----------------------------------------------------
SEEK_CUR Current position.
SEEK_END End of file.
SEEK_SET Beginning of file.
------------------------------------------------------------------------------
6.34 Set the current file position of stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fsetpos
[Syntax]
#include <stdio.h>
int fsetpos( FILE *stream, fpos_t *pos ) ;
[Arguments]
stream Pointer to a FILE structure.
pos Pointer to a position indicator to be stored.
[Return]
Returns zero if successful. If not, returns non-zero value and sets
an one of following values, which are defined in stdio.h, in a global
variable "errno".
Symbol Meaning
---------------+-----------------------------------------------------
EBADF File handle linked to the specified stream is
invalid, or cannot be accessed.
EINVAL Specified stream is invalid.
[Description]
Restores a file position indicator of the specified stream to "pos"
which has been gotten by the previous "fgetpos" function. This
function clears the end of file indicator and cancels the result of
"ungetc" function to the stream. Data format of "pos" is internal
one, it is used only by "fgetpos" and "fsetpos" functions.
------------------------------------------------------------------------------
6.35 Get the current file pointer. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
ftell
[Syntax]
#include <stdio.h>
long ftell( FILE *stream ) ;
[Arguments]
stream Pointer to a FILE structure.
[Return]
Returns the current file pointer. If any error, returns -1L and sets
an one of following values, which are defined in stdio.h, in a global
variable "errno".
Symbol Meaning
---------------+-----------------------------------------------------
EBADF File handle linked to the specified stream is
invalid, or cannot be accessed.
EINVAL Specified stream is invalid.
[Description]
Gets the current file pointer linked to the stream. This value is a
offset from the beginning of stream. A file pointer of a stream
which is opened with text mode may not coincide with the physical
offset, because a pair of carriage return and line feed (CR+LF) is
replaced with a line feed character(LF) in text mode. The current
file position of the file which has been opened with appending mode
is not the next writing position but the last reading/writing
operation position. For example, if the last operation to the file
which has been opened with appending mode is reading, the file
position is not the one in which the next writing operation will be
done but the next reading operation. In case that any reading/writing
operations have not been done to for appending mode file, the current
file position is the beginning of file.
------------------------------------------------------------------------------
6.36 Rewind the current file pointer to the top of file. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
rewind
[Syntax]
#include <stdio.h>
void rewind( FILE *stream ) ;
[Arguments]
stream Pointer to a FILE structure.
[Return]
------
[Description]
Rewind a file pointer linked to the stream to the beginning of file.
"rewind" function clears an error indicator of the stream, but
"fseek" doesn't. "rewind" is equivalent to the following "fseek"
except above.
Both "rewind" and "fseek" functions clear the end of file indicator.
"fseek" function returns a value whether a pointer movement has been
done successfully or not, but "rewind" doesn't. It is possible to
clear the keyboard buffer by calling "rewind" function to the
standard input stream (stdin) linked to the keyboard by default.
------------------------------------------------------------------------------
6.37 Reset error indicator of a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
clearerr
[Syntax]
#include <stdio.h>
void clearerr( FILE *stream ) ;
[Arguments]
stream Pointer to a FILE structure.
[Return]
------
[Description]
Rests the error indicator and the end of file indicator. The error
indicator is not cleared automatically. If once the error indicator
of specified stream is set, operations to the stream return the error
code until calling one of "clearerr", "fseek", "fsetpos" and
"rewind".
------------------------------------------------------------------------------
6.38 Test for end-of-file. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
feof
[Syntax]
#include <stdio.h>
int feof( FILE *stream ) ;
[Arguments]
stream Pointer to a FILE structure.
[Return]
Returns non-zero value if any input operations have been done beyond
the end of file, or zero if not. This function doesn't return any
error code.
[Description]
Tests whether reaching to the end of stream or not. Any operations
after once reaching to the end of steam return the end of file
indicator until the stream is closed or one of "clearerr", "fseek",
"fsetpos" and "rewind" is called.
------------------------------------------------------------------------------
6.39 Test for error on stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
ferror
[Syntax]
#include <stdio.h>
int ferror( FILE *stream ) ;
[Arguments]
stream Pointer to a FILE structure.
[Return]
Returns zero if no error on the stream, otherwise non-zero value.
[Description]
Test whether any read/write error occurs on a file linked to the
stream. If once any error has been occurred, the error indicator of
the stream is still ON until the stream is closed or one of
"clearerr" and "rewind" functions is called.
------------------------------------------------------------------------------
6.40 Print error message. <Main>
------------------------------------------------------------------------------
[Name]
perror
[Syntax]
#include <stdio.h>
void perror( const char *string ) ;
[Arguments]
string Error message to be displayed.
[Return]
------
[Description]
Displays an error message to the standard error output (stderr).
"string" is displayed first, then a colon (':') and a system error
message about the library call which has been occurred the latest
error, and last a newline is output. If "string" is NULL pointer or
a pointer to null string, only system error message is displayed. A
error code is stored in a global variable "errno" defined in errno.h.
A system error message is read from "sys_errlist", an array of
messages sorted by error code. "perror" function uses "errno" as a
index of "sys_errlist" to display an error message. "sys_nerr"
variable is the maximum element number of "sys_errlist" array. It is
necessary to call "perror" function just after library error to
display exactly. Otherwise, the following library calls may overwrite
"errno". Values which are stored in "errno" at error are original
ones of C Executor. These are not compatible with any PCs (MS-DOS
machines, etc.) and may be changed in the future. So, programming
that "errno" is handling is not recommended because it may not works
correctly in the future.
7. General utilities ( stdlib.h )
------------------------------------------------------------------------------
7.1 Convert string to int value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
atoi
[Syntax]
#include <stdlib.h>
int atoi( const char *nptr ) ;
[Arguments]
nptr Pointer to a string.
[Return]
Returns a converted value of int type.
[Description]
Converts a strings pointed by "nptr" to integer value.
Format of strings is as follows.
(whitespaces)(+,-)numeric_characters
------------------------------------------------------------------------------
7.2 Convert string to long value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
atol
[Syntax]
#include <stdlib.h>
long atol( const char *nptr ) ;
[Arguments]
nptr Pointer to a string.
[Return]
Returns a converted value of long type.
[Description]
Converts a strings pointed by "nptr" to long integer value.
Format of strings is as follows.
(whitespaces)(+,-)numeric_characters
------------------------------------------------------------------------------
7.3 Convert string to long value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strtol
[Syntax]
#include <stdlib.h>
long strtol( const char *nptr, char **endptr, int base ) ;
[Arguments]
nptr Pointer to a string.
endptr Pointer which points the position where reading is
stopped.
base Base number.
[Return]
Returns a converted value of long type. If overflow, returns
LONG_MAX or LONG_MIN and sets ERANGE in a global variable "errno".
[Description]
Converts a string pointed by "nptr" to long integer value using
"base" as a base number of conversion.
Format of strings is as follows.
(whitespaces)(+,-)(0)(x,X)(numeric_characters)
[Name]
strtoul
[Syntax]
#include <stdlib.h>
unsigned long strtoul( const char *nptr, char **endptr, int base ) ;
[Arguments]
nptr Pointer to a string.
endptr Pointer which points the position where reading is
stopped.
base Base number.
[Return]
Returns a converted value of unsigned long type. If overflow,
returns ULONG_MAX and sets ERANGE in a global variable "errno".
[Description]
Converts a string pointed by "nptr" to unsigned long integer value
using "base" as a base number of conversion.
Format of strings is as follows.
(whitespaces)(+,-)(0)(x,X)(numeric_characters)
[Name]
rand
[Syntax]
#include <stdlib.h>
int rand( void ) ;
[Arguments]
------
[Return]
Returns a pseudo random number.
[Description]
Returns a pseudo random number between 0 and 32767. "srand" function
initializes a series of random number.
------------------------------------------------------------------------------
7.6 Seed pseudo-random number generator. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
srand
[Syntax]
#include <stdlib.h>
void srand( unsigned int seed ) ;
[Arguments]
seed Number of new series.
[Return]
------
[Description]
Initializes a series of random number generated by "rand" function.
------------------------------------------------------------------------------
7.7 Allocate memory block initialized by 0. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
calloc
[Syntax]
#include <stdlib.h>
void *calloc( size_t num, size_t size ) ;
[Arguments]
num Number of elements.
size Byte size of element.
[Return]
Returns pointer to the allocated space. To get other type pointer
than (void *), cast the return value. If insufficient memory,
returns NULL.
[Description]
Allocates a memory block initialized by zero. That memory block is
composed of "num" elements whose size is "size" bytes. Each element
is initialized by zero. Test always the return value even if
requested memory size is small.
------------------------------------------------------------------------------
7.8 Free memory block. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
free
[Syntax]
#include <stdlib.h>
void free( void *memblock ) ;
[Arguments]
memblock Memory block already allocated. If NULL, it is
ignored.
[Return]
------
[Description]
Frees allocated memory block. "memblock" is a memory block which was
already allocated by "calloc", "malloc" or "realloc" function. Byte
size to be freed is one which was specified at memory allocation.
Deallocated memory block will be used for the next memory
allocations. If any invalid pointer is specified, any error may
occur in the future allocations. "Invalid pointer" is one which was
set without correct allocations.
------------------------------------------------------------------------------
7.9 Allocate memory block. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
malloc
[Syntax]
#include <stdlib.h>
void *malloc( size_t size ) ;
[Arguments]
size Byte size to be allocated.
[Return]
Returns a void pointer to the allocated memory block. A return value
can align with any object type. To get other type pointer than
(void *), cast the return value. If insufficient memory, returns
NULL.
[Description]
Allocates a memory block whose size is "size" bytes at least. More
free space than "size" bytes is used for allocation because of a
alignment and management information. Test always the return value
even if requested memory size is small.
------------------------------------------------------------------------------
7.10 Reallocate memory block. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
realloc
[Syntax]
#include <stdlib.h>
void *realloc( void *memblock, size_t size ) ;
[Arguments]
memblock Memory block already allocated.
size Byte size to be allocated.
[Return]
Returns a void pointer to the reallocated memory block. A return
value can align with any object type. To get other type pointer
than (void *), cast the return value. If "size" is zero and
"memblock" is not NULL, the current block is freed and the return
value is NULL. If insufficient memory for reallocation, the current
block is kept and the return value is NULL.
[Description]
Reallocates the memory block. This changes size of already allocated
memory block. If a new block is placed in the other position,
contents in the original block is kept. If "memblock" is NULL,
"realloc" function works as same as "malloc" function, allocates a
new block of "size" bytes. If "size" is not NULL, it must be a
pointer which was returned by "calloc", "malloc" or "realloc"
function before. If any invalid pointer is specified, any errors may
occur by incorrect allocation.
------------------------------------------------------------------------------
7.11 Perform binary search. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
bsearch
[Syntax]
#include <stdlib.h>
void *bsearch( const void *key, const void *base,
size_t nmemb, size_t size,
int (*compar)( const void *, const void *) ) ;
[Arguments]
key Data to be searched.
base Pointer to the top of the array.
nmemb Element number of the array.
size Size of an element of the array.
compar Pointer to the user definition function which
compares two elements.
[Return]
Returns a pointer to the matching element. If not found, returns
NULL.
[Description]
Searches the specified data in the specified array. The array must
be already sorted. "bsearch" function calls "compar" function for
searching. The return value of "compar" function must follow the
following rule.
Return Comparison result
-----------------+---------------------------
less than 0 1st arg. < 2nd arg.
equal to 0 1st arg. = 2nd arg.
greater than 0 1st arg. > 2nd arg.
------------------------------------------------------------------------------
7.12 Perform quick sort. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
qsort
[Syntax]
#include <stdlib.h>
void qsort( const void *base, size_t nmemb, size_t size,
int (*compar)( const void *, const void *) ) ;
[Arguments]
base Pointer to the top of the array (its order will be
changed by sorting.)
nmemb Element number of the array.
size Size of an element of the array.
compar Pointer to the user definition function which
compares two elements.
[Return]
------
[Description]
Performs quick sorting of the specified array. "qsort" function
calls "compar" function for searching. The return value of "compar"
function must follow the following rule.
[Name]
abs
[Syntax]
#include <stdlib.h>
int abs( int j ) ;
[Arguments]
j Value which is converted to absolute.
[Return]
Returns the absolute value of "j".
[Description]
Returns the absolute value of integer "j".
------------------------------------------------------------------------------
7.14 Get quotient and remainder. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
div
[Syntax]
#include <stdlib.h>
struct div_t {
int quot ;
int rem ;
} *div( int numer, int denum ) ;
[Arguments]
numer Dividend.
denum Divisor.
[Return]
Returns a structure "div_t".
[Description]
Divides integer value "number" by integer value "denum", and returns
the quotient and remander. Zero value as "denum" causes a system
error. Check values before calling this.
------------------------------------------------------------------------------
7.15 Get absolute value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
labs
[Syntax]
#include <stdlib.h>
long labs( long j ) ;
[Arguments]
j Value which is converted to absolute.
[Return]
Returns the absolute value of "j".
[Description]
Returns the absolute value of long integer "j".
------------------------------------------------------------------------------
7.16 Get quotient and remainder. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
ldiv
[Syntax]
#include <stdlib.h>
struct ldiv_t {
long quot ;
long rem ;
} *ldiv( long numer, long denum ) ;
[Arguments]
numer Dividend.
denum Divisor.
[Return]
Returns a structure "ldiv_t".
[Description]
Divides long integer value "number" by long integer value "denum",
and returns the quotient and remander. Zero value as "denum" causes
a system error. Check values before calling this.
------------------------------------------------------------------------------
7.17 Convert string to double value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
atof
[Syntax]
#include <stdlib.h>
double atof( const char *nptr ) ;
[Arguments]
nptr Pointer to a string.
[Return]
Returns a converted value of double type.
[Description]
Converts a strings pointed by "nptr" to double type value.
Format of strings is as follows.
(whitespaces)(+,-)num(.num)((d,D,e,E )(+,-)num)
num: numeric_characters
------------------------------------------------------------------------------
7.18 Convert string to double value. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strtod
[Syntax]
#include <stdlib.h>
double strtod( const char *nptr, char **endptr ) ;
[Arguments]
nptr Pointer to a string.
endptr Pointer which points the position where reading is
stopped.
[Return]
Returns a converted value of double type. If overflow,
returns +/-HUGE_VAL. If underflow, returns 0. In both case, sets
ERANGE in a global variable "errno".
[Description]
Converts a string pointed by "nptr" to double type value.
Format of strings is as follows.
(whitespaces)(+,-)num(.num)((d,D,e,E )(+,-)num)
num: numeric_characters
------------------------------------------------------------------------------
8.1 Copy a memory block. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
memcpy
[Syntax]
#include <string.h>
void *memcpy( void *s1, const void *s2, size_t n ) ;
[Arguments]
s1 Pointer to the destination.
s2 Pointer to the source.
n Byte count.
[Return]
Returns a pointer as same as "s1".
[Description]
Copies "n" byte data from the location specified by "s2" to the
location specified by "s1". If the source and the destination are
overlapped, the result is undefined. In this case, use "memmove"
function.
------------------------------------------------------------------------------
8.2 Move a memory block. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
memmove
[Syntax]
#include <string.h>
void *memmove( void *s1, void *s2, size_t n ) ;
[Arguments]
s1 Pointer to the destination.
s2 Pointer to the source.
n Byte count.
[Return]
Returns a pointer as same as "s1".
[Description]
Moves "n" byte data from the location specified by "s2" to the
location specified by "s1". The memory block is copied correctly
even if the source and the destination are overlapped.
------------------------------------------------------------------------------
8.3 Copy a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strcpy
[Syntax]
#include <string.h>
char *strcpy( char *s1, const char *s2 ) ;
[Arguments]
s1 Pointer to the destination.
s2 Pointer to the source.
[Return]
Returns a pointer as same as "s1".
[Description]
Copies a string pointed by "s2" to the location pointed by "s1". If
the source and the destination are overlapped, the result is
undefined.
------------------------------------------------------------------------------
8.4 Copy a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strncpy
[Syntax]
#include <string.h>
char *strncpy( char *s1, const char *s2, size_t n ) ;
[Arguments]
s1 Pointer to the destination.
s2 Pointer to the source.
n Character count.
[Return]
Returns a pointer as same as "s1".
[Description]
Copies a string of "n" characters pointed by "s2" to the location
pointed by "s1". If the length of "s2" string is longer than "n",
a null character is not added to the copied string. If the length
of "s2" is shorter than "n", null characters are added to the copied
string until "n" bytes in total. If the source and the destination
are overlapped, the result is undefined.
------------------------------------------------------------------------------
8.5 Concatenate a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strcat
[Syntax]
#include <string.h>
char *strcat( char *s1, const char *s2 ) ;
[Arguments]
s1 Pointer to the destination string.
s2 Pointer to the string to be concatenated.
[Return]
Returns a pointer as same as "s1".
[Description]
Concatenates a strings pointed by "s2" to the last of a string
pointed by "s1". A null character is added at last.
------------------------------------------------------------------------------
8.6 Concatenate a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strncat
[Syntax]
#include <string.h>
char *strncat( char *s1, const char *s2, size_t n ) ;
[Arguments]
s1 Pointer to the destination string.
s2 Pointer to the string to be concatenated.
n Character count to be concatenated.
[Return]
Returns a pointer as same as "s1".
[Description]
Concatenates a string of "n" characters pointed by "s2" to the last
of a string pointed by "s1". In the case of both the length of "s2"
string is longer and shorter than "n", a null character is added to
the copied string. This returns a pointer which is specified as "s1".
------------------------------------------------------------------------------
8.7 Compare two memory blocks. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
memcmp
[Syntax]
#include <string.h>
int memcmp( const void *s1, const void *s2, size_t n ) ;
[Arguments]
s1 Pointer to a memory block to be compared.
s2 Pointer to a memory block to be compared.
n Byte count to be compared.
[Return]
Returns the comparison result.
[Description]
Compare "n" byte data in the location pointed by "s1" with one by
"s2".
------------------------------------------------------------------------------
8.8 Compare two strings. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strcmp
[Syntax]
#include <string.h>
int strcmp( const char *s1, const char *s2 ) ;
[Arguments]
s1 Pointer to a string to be compared.
s2 Pointer to a string to be compared.
[Return]
Returns the comparison result.
[Description]
Compares a string pointed by "s1" with one by "s2".
------------------------------------------------------------------------------
8.9 Compare two strings. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strncmp
[Syntax]
#include <string.h>
int strncmp( const char *s1, const char *s2, size_t n ) ;
[Arguments]
s1 Pointer to a string to be compared.
s2 Pointer to a string to be compared.
n Character count to be compared.
[Return]
Returns the comparison result.
[Description]
Compares "n" characters of a string pointed by "s1" with one by "s2".
------------------------------------------------------------------------------
8.10 Find a character in a memory block. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
memchr
[Syntax]
#include <string.h>
void *memchr( const void *s, int c, size_t n ) ;
[Arguments]
s Pointer to a memory block in which data is searched.
c Data to be searched.
n Character count to be searched.
[Return]
Returns a pointer to the first matching data. If not found, returns
NULL.
[Description]
Searches "c" in "n" bytes of the memory block specified by "s", and
returns the location of the first matching data. "c" is converted to
"unsigned char".
------------------------------------------------------------------------------
8.11 Find a character in a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strchr
[Syntax]
#include <string.h>
char *strchr( const char *s, int c ) ;
[Arguments]
s Pointer to a string in which a character is searched.
c Character to be searched.
[Return]
Returns a pointer to the first matching location. If not found,
returns NULL.
[Description]
Searches "c" in a string pointed by "s", and returns the location of
the first matching character. "c" is converted to "char".
------------------------------------------------------------------------------
8.12 Get string length which doesn't include a character. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strcspn
[Syntax]
#include <string.h>
size_t strcspn( const char *s1, const char *s2 ) ;
[Arguments]
s1 Pointer to a string.
s2 Pointer to a string.
[Return]
Returns length from the top of "s1" to the part in which any
characters of "s2" are not contained.
[Description]
Returns length from the top of string "s1" to the part of "s1" in
which any characters included in "s2" are not contained.
------------------------------------------------------------------------------
8.13 Find a character position in a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strpbrk
[Syntax]
#include <string.h>
char *strpbrk( const char *s1, const char *s2 ) ;
[Arguments]
s1 Pointer to a string.
s2 Pointer to a string.
[Return]
Returns a pointer to the first position matching to the one of
characters included in string "s2". If not matching character,
returns NULL.
[Description]
Searches one of characters included in string "s2" from the top of
the string "s1", and returns the first matching position.
------------------------------------------------------------------------------
8.14 Find the last character in a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strrchr
[Syntax]
#include <string.h>
char *strrchr( const char *s, int c ) ;
[Arguments]
s Pointer to a string in which a character is searched.
c Character to be searched.
[Return]
Returns a pointer to the last matching location. If not found,
returns NULL.
[Description]
Searches "c" in a string pointed by "s", and returns the location of
the last matching character. "c" is converted to "char".
------------------------------------------------------------------------------
8.15 Get string length composed by specified character. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strspn
[Syntax]
#include <string.h>
size_t strspn( const char *s1, const char *s2 ) ;
[Arguments]
s1 Pointer to a string.
s2 Pointer to a string.
[Return]
Returns length from the top of "s1" to the part in which one of
characters of "s2" is contained.
[Description]
Returns length from the top of string "s1" to the part of "s1" in
which one of characters included in "s2" is contained.
------------------------------------------------------------------------------
8.16 Find a string in a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strstr
[Syntax]
#include <string.h>
char *strstr( const char *s1, const char *s2 ) ;
[Arguments]
s1 Pointer to a string.
s2 Pointer to a string.
[Return]
Returns a pointer to the first matching location in the string "s1".
If not found, returns NULL.
[Description]
Searches a string "s1" in a string "s1", and returns the pointer to
the first matching location.
------------------------------------------------------------------------------
8.17 Get a token. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strtok
[Syntax]
#include <string.h>
char *strtok( char *s1, const char *s2 ) ;
[Arguments]
s1 Pointer to a string. (is changed by processing)
s2 Pointer to a string.
[Return]
Returns a pointer to the token. The token is a string terminated by
a null character. If no token, returns NULL.
[Description]
Divide a string "s1" into tokens using each characters of a string
"s2" as delimiters. At the first call, "strtok" searches the first
token, and returns a pointer to it. If the first character of the
string is any token, "strtok" ignores it. At the following calls,
specify NULL as the argument "s1". Note that "strtok" function
changes a string "s1".
------------------------------------------------------------------------------
8.18 Fill data in a memory block. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
memset
[Syntax]
#include <string.h>
void *memset( void *s, int c, size_t n ) ;
[Arguments]
s Pointer to a memory block in where "c" is filled.
c Data to be filled.
n Byte count.
[Return]
Returns a pointer as same as "s".
[Description]
Fills "c" in the "n" byte space from "s".
------------------------------------------------------------------------------
8.19 Get string length. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
strlen
[Syntax]
#include <string.h>
size_t strlen( const char *s ) ;
[Arguments]
s Pointer to a string.
[Return]
Returns length of string "s".
[Description]
Returns length of string "s".
9. Date and time ( time.h )
------------------------------------------------------------------------------
9.1 Get the current time. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
clock
[Syntax]
#include <time.h>
clock_t clock( void ) ;
[Arguments]
------
[Return]
Returns the current system time counter.
[Description]
Returns the value of the current system time counter. The system
time counter is the accumulated count from the system start-up
which is counted up every 8 msec.
------------------------------------------------------------------------------
9.2 Convert local time to calender time. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
mktime
[Syntax]
#include <time.h>
time_t mktime( struct tm *timeptr ) ;
[Arguments]
timeptr Pointer to a structure "tm".
[Return]
Returns a calender tim.
[Description]
Converts the local time data pointed by *timeptr to a calender time.
The specified structure "tm" is converted to the standard setting.
------------------------------------------------------------------------------
9.3 Get the current time. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
time
[Syntax]
#include <time.h>
time_t time( time_t *timer ) ;
[Arguments]
timer Pointer to a time.
[Return]
Returns the current time.
[Description]
Returns the current time as the accumulated second from 1/1/1970
00:00:00. If "timer" is not NULL, also stores the current time in
"*timer".
The time returned by this function is read from the calender clock
of the CNC device. If the calender clock is not set correctly, -1L
is returned.
------------------------------------------------------------------------------
9.4 Convert time to string. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
asctime
[Syntax]
#include <time.h>
char *asctime( const struct tm *timeptr ) ;
[Arguments]
timeptr Pointer to a structure "tm".
[Return]
Returns a pointer to a converted string.
[Description]
Converts a time data pointed by "timeptr" to a string. The format
of string is as follows.
"Sun Jan 01 00:00:00 1992\n"
| | | | | | | |
| | | | | | | +- Newline
| | | | | | +---- Year
| | | | | +--------- Second
| | | | +------------ Minute
| | | +--------------- Hour
| | +------------------ Date
| +--------------------- Month
+------------------------- Day
[Name]
ctime
[Syntax]
#include <time.h>
char *ctime( const time_t *timer ) ;
[Arguments]
timer Pointer to a tiemr.
[Return]
Returns a pointer to a converted string.
[Description]
Converts a time data pointed by "timer" to a string as the local
time. The format of string is as follows.
"Sun Jan 01 00:00:00 1992\n"
| | | | | | | |
| | | | | | | +- Newline
| | | | | | +---- Year
| | | | | +--------- Second
| | | | +------------ Minute
| | | +--------------- Hour
| | +------------------ Date
| +--------------------- Month
+------------------------- Day
[Name]
gmtime
[Syntax]
#include <time.h>
struct tm *gmtime( const time_t *timer ) ;
[Arguments]
timer Pointer to a timer.
[Return]
Returns a pointer to a converted structure "tm".
[Description]
Converts a timer pointed by "*timer" to a structure "tm" which
represents the Greenwich Mean Time. The second from 1/1/1970 00:00:00
is stored in "*timer". This value is usually the return value of
"time" function. The static buffer for the structure "tm" is shared
by "localtime" function.
------------------------------------------------------------------------------
9.7 Convert time to local time. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
localtime
[Syntax]
#include <time.h>
struct tm *localtime( const time_t *timer ) ;
[Arguments]
timer Pointer to a timer.
[Return]
Returns a pointer to a converted structure "tm".
[Description]
Converts a timer pointed by "*timer" to a structure "tm" which
represents the local time. The second from 1/1/1970 00:00:00 is
stored in "*timer". This value is usually the return value of "time"
function. The static buffer for the structure "tm" is shared by
"gmtime" function.
------------------------------------------------------------------------------
9.8 Compute the difference between the two times. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
difftime
[Syntax]
#include <time.h>
double difftime( time_t time1, time_t time2 ) ;
[Arguments]
time_1 Beginning time.
time_2 Ending time.
[Return]
Returns elapsed time in second between "time2" through "time1".
[Description]
Calculates the difference of time by subtracting "time1" from "time2".
3.2 MS-C extended C standard library
====================================
Lists of Functions
~~~~~~~~~~~~~~~~~~
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
_chdrive Change the current drive.
_dos_findfirst Find the first file whose attributes match the
specified ones.
_dos_findnext Find the next file whose attributes match the
specified ones.
_dos_getdiskfree Get disk informations.
_expand Change a memory block size.
_fcalloc Allocate an array initialized by 0 in memory.
_fexpand Change a memory block size.
_ffree Free a memory block.
_fmalloc Allocate a memory block.
_fmemchr Find a character in a memory block.
_fmemcmp Compare two memory blocks.
_fmemcpy Copy a memory block.
_fmemicmp Compare two memory blocks ignoring cases.
_fmemmove Move a memory block.
_fmemset Fill a memory block with a character.
_fmsize Get memory block size in heap.
_frealloc Reallocate memory block.
_fstrcat Concatenate a string.
_fstrchr Find a character in a string.
_fstrcmp Compare two strings.
_fstrcpy Copy a string.
_fstrcspn Get string length which doesn't include a character.
_fstricmp Compare two strings ignoring cases.
_fstrlen Get string length.
_fstrlwr Convert string to lowercase.
_fstrncat Concatenate a string.
_fstrncmp Compare two strings.
_fstrncpy Copy a string.
_fstrnicmp Compare two strings ignoring cases.
_fstrnset Fill a string with a character.
_fstrpbrk Find a character position in a string.
_fstrrchr Find the last character in a string.
_fstrrev Reverse characters in a string.
_fstrset Fill a string with a character.
_fstrspn Get string length composed by specified character.
_fstrstr Find a string in a string.
_fstrtok Get a token.
_fstrupr Convert string to uppercase.
_getdrive Get the current drive.
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
_lrotl Rotate an unsigned long left.
_lrotr Rotate an unsigned long right.
_msize Get memory block size in heap.
_rotl Rotate unsigned int left.
_rotr Rotate unsigned int right.
_tolower Convert to lowercase.
_toupper Convert to uppercase.
alloca Allocate a memory block in stack.
cabs Calculate the absolute value of complex number.
chdir Change the current directory.
close Close a file.
creat Create a file.
ecvt Convert double value to string.
eof Test the end of file.
fcvt Convert floating point value to string.
gcvt Convert floating point value and store it in a buffer.
getch Get a character from the console.
getcwd Get the current directory.
hypot Calculate the square root of the sum of two squares.
isascii Test for ASCII character.
itoa Convert an int value to a string.
kbhit Check inputting status of keyboard.
lseek Move the current file pointer.
ltoa Convert a long value to a string.
memicmp Compare two memory blocks ignoring cases.
mkdir Create a new directory.
open Open a file.
read Read data from a file.
rmdir Delete a directory.
stackavail Get available stack size.
strcmpi Compare two strings ignoring cases.
stricmp Compare two strings ignoring cases.
strlwr Convert string to lowercase.
strnicmp Compare two strings ignoring cases.
strnset Fill a string with a character.
strrev Reverse characters in a string.
strset Fill a string with a character.
strupr Convert string to uppercase.
swab Swap two bytes.
tell Get the current position of a file.
toascii Convert to a ASCII character.
ultoa Convert an unsigned long value to a string.
write Write data to a file.
btom Count characters.
chkctype Determine what the character type of the character of
interest is.
hantozen Convert a 1-byte character to the corresponding 2-byte
character.
isalkana Determine whether the character of interest is a
half-size alphabetic or katakana character.
isalnmkana Determine whether the character of interest is a
half-size alphanumeric or katakana character.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
isgrkana Determine whether the character of interest is a
printable ASCII character (except a half-size space).
iskana Determine whether the character of interest is a
printable half-size kana character (except a half-size
space).
iskanji Determine whether the character of interest is byte 1
of a 2-byte character.
iskanji2 Determine whether the character of interest is byte 2
of a 2-byte character.
iskmoji Determine whether the character of interest is a
half-size katakana character.
iskpun Determine whether the character of interest is a
half-size kana symbol.
ispnkana Determine whether the character of interest is a
half-size symbol.
isprkana Determine whether the character of interest is a
printable character.
jisalpha Determine whether the character of interest is a
full-size alphabetic character.
jisdigit Determine whether the character of interest is a
full-size numeric character.
jishira Determine whether the character of interest is a
full-size hiragana character.
jiskata Determine whether the character of interest is a
full-size katakana character.
jiskigou Determine whether the character of interest is a
full-size symbol.
jisl0 Determine whether the character of interest is a
JIS non-kanji character.
jisl1 Determine whether the character of interest is a
JIS level 1 kanji character.
jisl2 Determine whether the character of interest is a
JIS level 2 kanji character.
jislower Determine whether the character of interest is a
full-size lowercase alphabetic character.
jisprint Determine whether the character of interest is a
printable character.
jisspace Determine whether the character of interest is a
full-size space.
jistojms Convert a JIS kanji code to the corresponding
shifted JIS kanji code.
jisupper Determine whether the character of interest is a
full-size uppercase alphabetic character.
jiszen Determine whether the character of interest is a
2-byte character.
jmstojis Convert a shifted JIS kanji code to the
corresponding JIS kanji code.
jtohira Convert a full-size katakana character to the
corresponding full-size hiragana character.
jtokata Convert a full-size hiragana character to the
corresponding full-size katakana character.
jtolower Convert a full-size uppercase alphabetic character
to the corresponding full-size lowercase alphabetic
character.
jtoupper Convert a full-size lowercase alphabetic character
to the corresponding full-size uppercase alphabetic
character.
mtob Determine how many bytes are in a character string.
nthctype Determine what the character type of a character in
a character string is.
zentohan Convert a 2-byte character to the corresponding
1-byte character.
--------------------------------------------------------------------------
This is the display device that is equipped with FS30i. This name is
derived from the display control LSI (VGA compatible accelerator chip for PC)
used for them. The following 4 display modes are supported.
A. 640x400 dots, 16 colors for each dot, overlapped with the character
screen (80-column x 25-line).
B. 640x400 dots, 256 colors for each dot, not overlapped with the
character screen.
C. 640x480 dots, 16 colors for each dot, overlapped with the character
screen (80-column x 30-line).
D. 640x480 dots, 256 colors for each dot, not overlapped with the
character screen.
Call the crt_opengr function before calling of the other graphic functions
in the user application. Call the crt_closegr function after a series of
graphic drawings. The flow of the processing is as follows.
:
if ( crt_opengr() ) { /* open graphics */
/* initialize graphic screen */
_setvideomode( _98RESSCOLOR ) ;
:
}
:
: /* graphic drawings */
:
crt_closegr() ; /* close graphic */
:
The graphic drawings are not done without execution of the crt_opengr
function. ( _GRNOOUTPUT status will be returned.) The screen switching is
inhibited during opening graphics. It is enabled to switch the screen by
the execution of the crt_setswt( CRT_SWT_GREN ) function before opening
graphics, however, the graphics is closed by the screen switching during
opening graphics and graphic drawings are not done until the crt_opengr
function will be called again even if graphic functions are called.
The screen switching request during opening graphics (such as the screen
selection by MDI key) is being pending state until the graphics will be
closed, and the pending screen switching will be performed when the
crt_closegr function is called.
4. Multi-window display.
The multi-window displaying is not available for graphics. The graphic
screen is always displayed on the full screen even if the multi-windows of
character are being displayed.
Lists of MS-C compatible functions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
1. _arc Draw an arc or an elliptic arc.
2. _clearscreen Clear screen.
3. _ellipse Draw a circle or an ellipse.
4. _floodfill Paint the closed region.
5. _getactivepage Get the current active page number.
6. _getarcinfo Get the information of the previous arc
or pie.
7. _getbkcolor Get the current back ground color.
8. _getcolor Get the current fore ground color.
9. _getcurrentpositionGet the current position in the view
coordinate.
10. _getfillmask Get the current fill mask pattern.
11. _getfontinfo Get the current font information.
12. _getgtextextent Get the text extent by pixel unit.
13. _getgtextvector Get the output vector of text.
14. _getimage Get screen image.
15. _getkanji Get the font pattern of Kanji character.
16. _getlinestyle Get the current line style.
17. _getphyscoord Convert view coordinate into physical.
18. _getpixel Get color number the pixel.
19. _gettextposition Get the current output position of text.
20. _gettextwindow Get the text window border.
21. _getvideoconfig Get the graphic configuration.
22. _getviewcoord Convert physical coordinate into view.
23. _getvisualpage Get the current visual page number.
24. _getwritemode Get the current writing mode.
25. _grstatus Get the return status of graphic function.
26. _imagesize Get image buffer size.
27. _kanjisize Get font pattern size of Kanji character.
28. _lineto Draw a line.
29. _moveto Move the current graphic output position.
30. _outgtext Draw a text string using the current font.
31. _outmem Draw a text string in a memory.
32. _outtext Output a text string on the current position.
33. _pie Draw a pie figure.
34. _polygon Draw a polygon.
35. _putimage Put image data on the screen.
36. _rectangle Draw a rectangle.
37. _registerfonts Register font file.
38. _remapallpalette Map colors into all color palette.
39. _remappalette Map a color into a color palette.
40. _setactivepage Set the current active page number.
41. _setbkcolor Set the current back ground color.
42. _setcliprgn Set the clipping region.
43. _setcolor Set the current fore ground color.
44. _setfillmask Set the current fill mask pattern.
45. _setfont Set the current font.
46. _setgtextvector Set the current output vector of text.
47. _setlinestyle Set the current line style.
48. _setpixel Draw a pixel.
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
49. _settextposition Set the current output position of text.
50. _settextrows Set the text row number.
51. _settextwindow Set the text window.
52. _setvideomode Set the screen video mode.
53. _setvideomoderows Set the screen video mode and text row number.
54. _setvieworg Set the origin of the view port.
55. _setviewport Set the clipping region and the view
coordinate.
56. _setvisualpage Set the current visual page number.
57. _setwritemode Set the current writing mode.
58. _unregisterfonts Delete registered font file.
59. _wrapon Enable/disable line wrapping.
--------------------------------------------------------------------------
Function Reference
~~~~~~~~~~~~~~~~~~
------------------------------------------------------------------------------
1. Draw an arc or an elliptic arc. <Main>
------------------------------------------------------------------------------
[Name]
_arc
[Syntax]
#include <graph.h>
short _arc( short rsx, short rsy, short rex, short rey,
short vsx, short vsy, short vex, short vey ) ;
[Description]
Draws an arc or an elliptic arc.
[Compatibility]
[Name]
_clearscreen
[Syntax]
#include <graph.h>
void _clearscreen( short area ) ;
[Description]
Clears specified region and paint it by the current back ground color.
[Compatibility]
[Name]
_ellipse
[Syntax]
#include <graph.h>
short _ellipse( short fill, short rsx, short rsy,
short rex, short rey ) ;
[Description]
Draws a circle or an ellipse.
[Compatibility]
(3) There may be the difference from specified rectangle by the drawing
precision of this function.
(4) The painting operation may not be done correctly in case that
_GFILLINTERIOR is specfied in this function.
[Name]
_floodfill
[Syntax]
#include <graph.h>
short _floodfill( short sx, short sy, short boundary ) ;
[Description]
Paints the region, where is enclosed by specified border color, by the
current fill mask pattern.
[Compatibility]
(2) The painting may not be execute correctly in case that the same
color region as the current color exists in the enclosed region.
------------------------------------------------------------------------------
5. Get the current active page number. <Main>
------------------------------------------------------------------------------
[Name]
_getactivepage
[Syntax]
#include <graph.h>
short _getactivepage( void ) ;
[Description]
Gets the page number of the plane to be drawn.
[Compatibility]
This function is compatible with the "_getactivepage" function of
MS-C.
------------------------------------------------------------------------------
6. Get the information of the previous arc or pie. <Main>
------------------------------------------------------------------------------
[Name]
_getarcinfo
[Syntax]
#include <graph.h>
short _getarcinfo( struct _xycoord *start, struct _xycoord *end,
struct _xycoord *fillpoint ) ;
[Description]
Gets the view port coordinates of the arc or pie which has been
drawn just previously, and gets the start coordinate to paint a pie.
[Compatibility]
(1) This function gets the actual drawing start and end coordinates.
(2) The painting start coordinate may be different from what MS-C
calculates because the calculation method is different between C-EXE
and MS-C.
(1) The start point to paint a pie is calculated by supposing the closed
region of the arc which is drawn by the start and end points as same
as MS-C.
------------------------------------------------------------------------------
7. Get the current back ground color. <Main>
------------------------------------------------------------------------------
[Name]
_getbkcolor
[Syntax]
#include <graph.h>
long _getbkcolor( void ) ;
[Description]
Gets the current back ground color.
[Compatibility]
[Name]
_getcolor
[Syntax]
#include <graph.h>
short _getcolor( void ) ;
[Description]
Gets the palette number of the current fore ground color.
[Compatibility]
This function is compatible with the "_getcolor" function of MS-C.
------------------------------------------------------------------------------
9. Get the current position in the view coordinate. <Main>
------------------------------------------------------------------------------
[Name]
_getcurrentposition
[Syntax]
#include <graph.h>
struct _xycoord _getcurrentposition( void ) ;
[Description]
Gets the current position in the view coordinate.
[Compatibility]
This function is compatible with the "_getcurrentposition" function of
MS-C.
------------------------------------------------------------------------------
10. Get the current fill mask pattern. <Main>
------------------------------------------------------------------------------
[Name]
_getfillmask
[Syntax]
#include <graph.h>
unsigned char *_getfillmask( unsigned char *mask ) ;
[Description]
Gets the current fill mask pattern.
[Compatibility]
[Name]
_getfontinfo
[Syntax]
#include <graph.h>
short _getfontinfo( struct _fontinfo *fontbuffer ) ;
[Description]
Gets the current font information and stores it in the buffer.
[Compatibility]
[Name]
_getgtextextent
[Syntax]
#include <graph.h>
short _getgtextextent( unsigned char *text ) ;
[Description]
Gets the extent of the specified font by pixel unit on the current
font information
[Compatibility]
This function is compatible with the "_getgtextextent" function of
MS-C.
------------------------------------------------------------------------------
13. Get the output vector of text. <Main>
------------------------------------------------------------------------------
[Name]
_getgtextvector
[Syntax]
#include <graph.h>
struct _xycoord _getgtextvector( void ) ;
[Description]
Gets the output vector of the font text.
[Compatibility]
This function is compatible with the "_getgtextvector" function of
MS-C.
------------------------------------------------------------------------------
14. Get screen image. <Main>
------------------------------------------------------------------------------
[Name]
_getimage
[Syntax]
#include <graph.h>
void _getimage( short rsx, short rsy,
short rex, short rey, char *image ) ;
[Description]
Gets the screen image and stores it in memory.
[Compatibility]
[Name]
_getkanji
[Syntax]
#include <graph.h>
short _getkanji( unsigned short code, unsigned char *image ) ;
[Description]
Gets the font pattern of the specified Kanji character.
[Compatibility]
The character pattern format of MS-C for PC-9800 series and for PC-AT
are different each other. This function adopts the PC-9800 format.
The storing order of the character pattern array is as follows.
76543210 76543210
........ ........
.......# ...#....
.##..### ######..
...#...# ...#....
......## #####...
.##...#. .#..#...
...#..## #####...
........ .#......
...#..## #####...
...#.... .#......
...#.### ######..
..#..... #.#.....
..#....# ...#....
.##..##. ....##..
........ ........
........ ........
[Name]
_getlinestyle
[Syntax]
#include <graph.h>
unsigned short _getlinestyle( void ) ;
[Description]
Gets the current line style.
[Compatibility]
This function is compatible with the "_getlinestyle" function of MS-C.
------------------------------------------------------------------------------
17. Convert view coordinate into physical. <Main>
------------------------------------------------------------------------------
[Name]
_getphyscoord
[Syntax]
#include <graph.h>
struct _xycoord _getphyscoord( short x, short y ) ;
[Description]
Converts the view coordinate into the physical coordinate.
[Compatibility]
This function is compatible with the "_getphyscoord" function of MS-C.
------------------------------------------------------------------------------
18. Get color number the pixel. <Main>
------------------------------------------------------------------------------
[Name]
_getpixel
[Syntax]
#include <graph.h>
short _getpixel( short x, short y ) ;
[Description]
Gets the color number of the specified pixel.
[Compatibility]
This function is compatible with the "_getpixel" function of MS-C.
------------------------------------------------------------------------------
19. Get the current output position of text. <Main>
------------------------------------------------------------------------------
[Name]
_gettextposition
[Syntax]
#include <graph.h>
struct _rccoord _gettextposition( void ) ;
[Description]
Gets the current output position of the text.
[Compatibility]
This function is compatible with the "_gettextposition" function of
MS-C.
------------------------------------------------------------------------------
20. Get the text window border. <Main>
------------------------------------------------------------------------------
[Name]
_gettextwindow
[Syntax]
#include <graph.h>
void _gettextwindow( short *r1, short *c1, short *r2, short *c2 ) ;
[Description]
Gets the window border of the current text window.
[Compatibility]
This function is compatible with the "_gettextwindow" function of
MS-C.
------------------------------------------------------------------------------
21. Get the graphic configuration. <Main>
------------------------------------------------------------------------------
[Name]
_getvideoconfig
[Syntax]
#include <graph.h>
struct videoconfig *_getvideoconfig(
struct videoconfig *config ) ;
[Description]
Gets the information of the hardware about the graphic environment.
[Compatibility]
[Name]
_getviewcoord
[Syntax]
#include <graph.h>
struct _xycoord _getviewcoord( short x, short y ) ;
[Description]
Converts the physical coordinate into the view coordinate.
[Compatibility]
This function is compatible with the "_getviewcoord" function of MS-C.
------------------------------------------------------------------------------
23. Get the current visual page number. <Main>
------------------------------------------------------------------------------
[Name]
_getvisualpage
[Syntax]
#include <graph.h>
short _getvisualpage( void ) ;
[Description]
Gets the page number of the currently displayed page.
[Compatibility]
This function is compatible with the "_getvisualpage" function of
MS-C.
------------------------------------------------------------------------------
24. Get the current writing mode. <Main>
------------------------------------------------------------------------------
[Name]
_getwritemode
[Syntax]
#include <graph.h>
short _getwritemode( void ) ;
[Description]
Gets the current logical writing mode.
[Compatibility]
This function is compatible with the "_getwritemode" function of MS-C.
------------------------------------------------------------------------------
25. Get the return status of graphic function. <Main>
------------------------------------------------------------------------------
[Name]
_grstatus
[Syntax]
#include <graph.h>
short _grstatus( void ) ;
[Description]
Gets the status of the graphic function which has been executed just
before.
[Compatibility]
This function is compatible with the "_grstatus" function of MS-C.
------------------------------------------------------------------------------
26. Get image buffer size. <Main>
------------------------------------------------------------------------------
[Name]
_imagesize
[Syntax]
#include <graph.h>
long _imagesize( short rsx, short rsy, short rex, short rey ) ;
[Description]
Returns the required buffer size for storing the specified image data
by byte unit.
[Compatibility]
This function is compatible with the "_imagesize" function of MS-C.
------------------------------------------------------------------------------
27. Get font pattern size of Kanji character. <Main>
------------------------------------------------------------------------------
[Name]
_kanjisize
[Syntax]
#include <graph.h>
short _kanjisize( short code ) ;
[Description]
Returns the required buffer size for storing the specified font
pattern by byte unit.
[Compatibility]
This function is compatible with the "_kanjisize" function of MS-C.
------------------------------------------------------------------------------
28. Draw a line. <Main>
------------------------------------------------------------------------------
[Name]
_lineto
[Syntax]
#include <graph.h>
short _lineto( short x, short y ) ;
[Description]
Draws a line from the current pixel cursor to the specified
coordinate.
[Compatibility]
[Name]
_moveto
[Syntax]
#include <graph.h>
struct xycoord _moveto( short x, short y ) ;
[Description]
Moves the current graphic output position to the specified coordinate.
[Compatibility]
This function is compatible with the "_moveto" function of MS-C.
------------------------------------------------------------------------------
30. Draw a text string using the current font. <Main>
------------------------------------------------------------------------------
[Name]
_outgtext
[Syntax]
#include <graph.h>
void _outgtext( unsigned char *text ) ;
[Description]
Draws a text string on the specified pixel position of the screen
using the current font.
[Compatibility]
This function is compatible with the "_outgtext" function of MS-C.
------------------------------------------------------------------------------
31. Draw a text string in a memory. <Main>
------------------------------------------------------------------------------
[Name]
_outmem
[Syntax]
#include <graph.h>
void _outmem( char *text, short length ) ;
[Description]
Draws a text string of the specified length stored in the specified
memory buffer.
[Compatibility]
(2) The control code for only '\n' is processed in the text window. The
other contorl code such as '\t' is not processed.
[Name]
_outtext
[Syntax]
#include <graph.h>
void _outtext( char *text ) ;
[Description]
Outputs a text string on the current text position.
[Compatibility]
(1) The text string is displayed using text character. The graphic
output is not used.
(2) The control code for only '\n' is processed in the text window. The
other contorl code such as '\t' is not processed.
[Name]
_pie
[Syntax]
#include <graph.h>
short _pie( short fill, short rsx, short rsy, short rex, short rey,
short vsx, short vsy, short vex, short vey ) ;
[Description]
Draws a pie figure.
[Compatibility]
(3) There may be the difference from specified rectangle by the drawing
precision of this function.
[Name]
_polygon
[Syntax]
#include <graph.h>
short _polygon( short fill, struct xycoord *points,
short numpoints ) ;
[Description]
Draws a polygon or paints it.
[Compatibility]
[Name]
_putimage
[Syntax]
#include <graph.h>
void _putimage( short sx, short sy, char *image, short action ) ;
[Description]
Reads image data from the memory and draws it on the screen.
[Compatibility]
[Name]
_rectangle
[Syntax]
#include <graph.h>
short _rectangle( short fill, short rsx, short rsy,
short rex, short rey ) ;
[Description]
Draws a rectangle or paints it.
[Compatibility]
[Name]
_registerfonts
[Syntax]
#include <graph.h>
short _registerfonts( unsigned char *pathname ) ;
[Description]
Registers font file and initializes the font library.
[Compatibility]
(1) This function doesn't check the specified file pathname. Therefore,
the return value of the "_grstatus" function is always "_GROK".
The return value of this function is always "1".
[Name]
_remapallpalette
[Syntax]
#include <graph.h>
short _remapallpalette( long *colors ) ;
[Description]
Changes color values of all color palettes.
[Compatibility]
[Remarks]
When the video mode is "_98RES16COLOR(101)", the number of the color
palette is 256 in C Executor, but this function changes only 16
palettes for compatibility with MS-C.
------------------------------------------------------------------------------
39. Map a color into a color palette. <Main>
------------------------------------------------------------------------------
[Name]
_remappalette
[Syntax]
#include <graph.h>
long _remappalette( short index, long color ) ;
[Description]
Changes color value of the specified color palette.
[Compatibility]
[Name]
_setactivepage
[Syntax]
#include <graph.h>
short _setactivepage( short page ) ;
[Description]
Sets the graphic plane to be drawn.
[Compatibility]
This function is compatible with the "_setactivepage" function of
MS-C.
------------------------------------------------------------------------------
41. Set the current back ground color. <Main>
------------------------------------------------------------------------------
[Name]
_setbkcolor
[Syntax]
#include <graph.h>
long _setbkcolor( long color ) ;
[Description]
Sets the current back ground color.
[Compatibility]
_GRPARAMETERALTERED
[Name]
_setcliprgn
[Syntax]
#include <graph.h>
void _setcliprgn( short rsx, short rsy, short rex, short rey ) ;
[Description]
Sets the clipping region for the graphic output.
[Compatibility]
This function is compatible with the "_setcliprgn" function of MS-C.
------------------------------------------------------------------------------
43. Set the current fore ground color. <Main>
------------------------------------------------------------------------------
[Name]
_setcolor
[Syntax]
#include <graph.h>
short _setcolor( short color ) ;
[Description]
Sets the color which is corresponding to the specified palette number
as the current color.
[Compatibility]
This function is compatible with the "_setcolor" function of MS-C.
------------------------------------------------------------------------------
44. Set the current fill mask pattern. <Main>
------------------------------------------------------------------------------
[Name]
_setfillmask
[Syntax]
#include <graph.h>
void _setfillmask( unsigned char *mask ) ;
[Description]
Sets the current fill mask pattern.
[Compatibility]
(1) In C Executor, this function sets the fill mask pattern as the
default status when the mask data is "full(-1)" for the painting
performance.
------------------------------------------------------------------------------
45. Set the current font. <Main>
------------------------------------------------------------------------------
[Name]
_setfont
[Syntax]
#include <graph.h>
short _setfont( unsigned char *options ) ;
[Description]
Sets the current font for "_outgtext" function.
[Compatibility]
(2) Specify the typename placed in single quotation marks ('') after
the option "t".
The available typenames are as follows.
------------------------------------------------------------------
Typename Character set
------------------------------------------------------------------
standard ANK character set (Standard)
graph1 ANK character set (Graphic 1)
graph2 ANK character set (Graphic 2)
graph3 ANK character set (Graphic 3)
large ANK character set (Large character)
micro ANK character set (Small character)
fanuc Kanji character set (FANUC Kanji set)
[Name]
_setgtextvector
[Syntax]
#include <graph.h>
struct _xycoord _setgtextvector( short x, short y ) ;
[Description]
Sets the current output vector of the font text.
[Compatibility]
[Name]
_setlinestyle
[Syntax]
#include <graph.h>
void _setlinestyle( unsigned short mask ) ;
[Description]
Sets the current line style.
[Compatibility]
This function is compatible with the "_setlinestyle" function of MS-C.
------------------------------------------------------------------------------
48. Draw a pixel. <Main>
------------------------------------------------------------------------------
[Name]
_setpixel
[Syntax]
#include <graph.h>
short _setpixel( short x, short y ) ;
[Description]
Draws a pixel in specified position by the current color.
[Compatibility]
This function is compatible with the "_setpixel" function of MS-C.
------------------------------------------------------------------------------
49. Set the current output position of text. <Main>
------------------------------------------------------------------------------
[Name]
_settextposition
[Syntax]
#include <graph.h>
struct _rccoord _settextposition( short row, short column ) ;
[Description]
Move the current position for outputting text.
[Compatibility]
This function is compatible with the "_settextposition" function of
MS-C.
------------------------------------------------------------------------------
50. Set the text row number. <Main>
------------------------------------------------------------------------------
[Name]
_settextrows
[Syntax]
#include <graph.h>
short _settextrows( short rows ) ;
[Description]
Sets the text row number.
[Compatibility]
(1) The maximum line number of each video mode is set for every
specification.
(1) The maximum line number of the video mode is set by specifying
"_MAXTEXTROWS(-1)".
[Name]
_settextwindow
[Syntax]
#include <graph.h>
void _settextwindow( short r1, short c1, short r2, short c2 ) ;
[Description]
Sets the current text window.
[Compatibility]
[Remarks]
The "crt_setmode" function makes the current text window ineffective.
------------------------------------------------------------------------------
52. Set the screen video mode. <Main>
------------------------------------------------------------------------------
[Name]
_setvideomode
[Syntax]
#include <graph.h>
short _setvideomode( short mode ) ;
[Description]
Selects the display mode of the screen.
[Compatibility]
VGA Graphic
--------------------------------------------------------------------
Mode Size(Text) Palette (Color mode)
--------------------------------------------------------------------
_98RESS16COLOR 640x400(80x25) 16 colors (PC-98)
_98RESS8COLOR
(_98RESSCOLOR)
--------------------------------------------------------------------
_98RES16COLOR 640x400 256 colors (PC-98)
_98RES8COLOR
(_98RESCOLOR)
--------------------------------------------------------------------
_VRES16COLOR 640x480(80x30) 16 colors (PC-AT)
_VRES16EXCOLOR
--------------------------------------------------------------------
_VRES256COLOR 640x480 256 colors (PC-AT)
--------------------------------------------------------------------
_98TEXT80 Text mode(80x25) 16 colors
_TEXTC80
--------------------------------------------------------------------
This function sets the following modes for "_DEFAULTMODE",
"_MAXCOLORMODE" or "_MAXRESMODE".
-----------------------------------
Mode VGA Graphic
-----------------------------------
_DEFAULTMODE _98TEXT80,_TEXTC80
_MAXCOLORMODE _VRES256COLOR
_MAXRESMODE _VRES16COLOR
-----------------------------------
(2) Use "_CEXERES16COLOR" mode for arbitrary plane size and text mode.
Symbol "_CEXERES16COLOR" is definded in "graph.h".
#include <crt.h>
#include <graph.h>
short _setvideomode( _CEXERES16COLOR, short origin,
short height, short TXmode ) ;
(4) The cursor current position is initialized and moved to the home
position after the execution of this function.
[Remarks]
Use "crt_setmode" function or "_setvideomode( _CEXRES16COLOR,.. )"
to change the text mode.
------------------------------------------------------------------------------
53. Set the screen video mode and text row number. <Main>
------------------------------------------------------------------------------
[Name]
_setvideomoderows
[Syntax]
#include <graph.h>
short _setvideomoderows( short mode, short rows ) ;
[Description]
Sets the video mode for the text operation and sets the text row
number.
[Compatibility]
(2) The text row number is always set as the maximum line number of the
specified video mode even if any "rows" is specified.
[Remarks]
Use "crt_setmode" function to change the text mdoe.
------------------------------------------------------------------------------
54. Set the origin of the view port. <Main>
------------------------------------------------------------------------------
[Name]
_setvieworg
[Syntax]
#include <graph.h>
struct xycoord _setvieworg( short x, short y ) ;
[Description]
Moves the origin of the view port to the specified physical position.
[Compatibility]
This function is compatible with the "_setvieworg" function of MS-C.
------------------------------------------------------------------------------
55. Set the clipping region and the view coordinate. <Main>
------------------------------------------------------------------------------
[Name]
_setviewport
[Syntax]
#include <graph.h>
void _setviewport( short rsx, short rsy, short rex, short rey ) ;
[Description]
Restricts to the graphic output in the specified region on the
screen and sets the origin of the viewport coordinate on its
left-upper corner.
[Compatibility]
This function is compatible with the "_setviewport" function of MS-C.
------------------------------------------------------------------------------
56. Set the current visual page number. <Main>
------------------------------------------------------------------------------
[Name]
_setvisualpage
[Syntax]
#include <graph.h>
short _setvisualpage( short page ) ;
[Description]
Set the page number of the currently displayed page.
[Compatibility]
This function is compatible with the "_setvisualpage" function of
MS-C.
------------------------------------------------------------------------------
57. Set the current writing mode. <Main>
------------------------------------------------------------------------------
[Name]
_setwritemode
[Syntax]
#include <graph.h>
short _setwritemode( short action ) ;
[Description]
Sets the current logical writing mode.
[Compatibility]
[Name]
_unregisterfonts
[Syntax]
#include <graph.h>
void _unregisterfonts( void ) ;
[Description]
Delete registered font file and free the font library memory.
[Compatibility]
[Name]
_wrapon
[Syntax]
#include <graph.h>
short _wrapon( short option ) ;
[Description]
Enable or disable wrapping of the text line.
[Compatibility]
This function is compatible with the "_wrapon" function of MS-C.
MS-C graphic function compatibility list
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----------------------------------------------------------------------------
Name Function VGA C-Card
---------------------------------------------------------------+----+-------
_arc Draw an arc or an elliptic arc. x
_clearscreen Clear screen. x
_displaycursor Enable/disable the cursor.
_ellipse Draw a circle or an ellipse. x
_floodfill Paint the closed region. x
_getactivepage Get the current active page number. x
_getarcinfo Get the information of the previous x
arc or pie.
_getbkcolor Get the current back ground color. x
_getcolor Get the current fore ground color. x
_getcurrentposition Get the current position in the view x
coordinate.
_getfillmask Get the current fill mask pattern. x
_getfontinfo Get the current font information. x
_getgtextextent Get the text extent by pixel unit. x
_getgtextvector Get the output vector of text. x
_getimage Get screen image. x
_getkanji Get the font pattern of Kanji character. x
_getlinestyle Get the current line style. x
_getphyscoord Convert view coordinate into physical. x
_getpixel Get color number the pixel. x
_gettextcolor Get the current text color.
_gettextcursor Get the current cursor attribute.
_gettextposition Get the current output position of text. x
_gettextwindow Get the text window border. x
_getvideoconfig Get the graphic configuration. x
_getviewcoord Convert physical coordinate into view. x
_getvisualpage Get the current visual page number. x
_getwritemode Get the current writing mode. x
_grstatus Get the return status of graphic x
function.
_imagesize Get image buffer size. x
_kanjisize Get font pattern size of Kanji character. x
_lineto Draw a line. x
_moveto Move the current graphic output position. x
_outgtext Draw a text string using the current font. x
_outmem Draw a text string in a memory. x
_outtext Output a text string on the current x
position.
_pie Draw a pie figure. x
_polygon Draw a polygon. x
_putimage Put image data on the screen. x
_rectangle Draw a rectangle. x
_registerfonts Register font file. x
_remapallpalette Map colors into all color palette. x
_remappalette Map a color into a color palette. x
_scrolltextwindow Scroll the contents in the text window.
_setactivepage Set the current active page number. x
_setbkcolor Set the current back ground color. x
_setcliprgn Set the clipping region. x
----------------------------------------------------------------------------
Name Function VGA C-Card
---------------------------------------------------------------+----+-------
_setcolor Set the current fore ground color. x
_setfillmask Set the current fill mask pattern. x
_setfont Set the current font. x
_setgtextvector Set the current output vector of text. x
_setlinestyle Set the current line style. x
_setpixel Draw a pixel. x
_settextcolor Set the current text color.
_settextcursor Set the current cursor attribute.
_settextposition Set the current output position of text. x
_settextrows Set the text row number. x
_settextwindow Set the text window. x
_setvideomode Set the screen video mode. x
_setvideomoderows Set the screen video mode and text row x
number.
_setvieworg Set the origin of the view port. x
_setviewport Set the clipping region and the view x
coordinate.
_setvisualpage Set the current visual page number. x
_setwritemode Set the current writing mode. x
_unregisterfonts Delete registered font file. x
_wrapon Enable/disable line wrapping. x
----------------------------------------------------------------------------
Lists of C Executor original graphic functions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
1. gr_displaychar Draw a standard size character.
2. gr_displayfourlargeDraw a quad size character.
3. gr_displaysixlarge Draw a hex size character.
4. _putpattern Put monochrome image data.
5. _getpattern Get monochrome image data.
6. gr_dispstr Draw a standard size string.
7. gr_disp6str Draw a hex size string.
8. gr_bitblt Copy image data.
9. gr_disp4str Draw a quad size string.
10. gr_displaysmlchar Draw a small size character.
11. gr_dispsstr Draw a small size string.
12. gr_displayfchar Draw a FANUC character.
13. gr_dispfstr Draw a FANUC character string.
14. gr_disp9ifchar Draw 9-inch font character.
15. gr_disp9ifstr Draw 9-inch font character string.
16. mmc_line_b Draw a line between specified two points.
17. mmc_polyline Draw a polyline.
18. mmc_circle_b Draw a circle.
19. mmc_ellipse_b Draw an ellipse.
20. mmc_pie_b Draw a pie figure.
21. mmc_arc_b Draw an arc.
22. mmc_gettext Get character in the specified area.
23. mmc_puttext Put character data on memory to text screen.
24. mmc_textsize Get required byte size for getting character.
--------------------------------------------------------------------------
Function Reference
~~~~~~~~~~~~~~~~~~
------------------------------------------------------------------------------
1. Draw a standard size character. <Main>
------------------------------------------------------------------------------
[Name]
gr_displaychar
[Syntax]
#include <graph.h>
void gr_displaychar( int code, short cx, short cy,
short fg, short bg ) ;
[Arguments]
code Character code to be drawn.
cx, cy Coordinate of the left-upper corner at where the
character is drawn.
fg Character color.
bg Background color.
[Return]
------
[Description]
Draws the specified character whose size is same as the text's one
(i.e. 8 x 16 dots, 16 x 16 dots for Kanji character) on the graphic
screen.
Specify the character color and the background color using palette
index number. Only character is drawn if -32768 (0x8000) is specified
as the background color.
When specifying a 2-byte character code with the argument code, store
the first byte in the upper byte. When drawing, for example,
(SHIFT-JIS code 8ABF), specify as follows.
gr_displaychar (0x8ABF, ...)
------------------------------------------------------------------------------
2. Draw a quad size character. <Main>
------------------------------------------------------------------------------
[Name]
gr_displayfourlarge
[Syntax]
#include <graph.h>
void gr_displayfourlarge( int code, short cx, short cy,
short fg, short bg ) ;
[Arguments]
code Character code to be drawn.
cx, cy Coordinate of the left-upper corner at where the
character is drawn.
fg Character color.
bg Background color.
[Return]
------
[Description]
Draws the specified character whose dot matrix is 16 x 32 dots on the
graphic screen.
Specify the character color and the background color using palette
index number. Only character is drawn if -32768 (0x8000) is specified
as the background color. This function can't draw 2-byte characters
such as Japanese Kanji characters. It can draw only half-size charac-
ters whose codes are 0x20 to 0x7F.
------------------------------------------------------------------------------
3. Draw a hex size character. <Main>
------------------------------------------------------------------------------
[Name]
gr_displaysixlarge
[Syntax]
#include <graph.h>
void gr_displaysixlarge( int code, short cx, short cy,
short fg, short bg ) ;
[Arguments]
code Character code to be drawn.
cx, cy Coordinate of the left-upper corner at where the
character is drawn.
fg Character color.
bg Background color.
[Return]
------
[Description]
Draws the specified hex size character whose dot matrix is 24 x 32
dots on the graphic screen.
Specify the character color and the background color using palette
index number. Only character is drawn if -32768 (0x8000) is specified
as the background color. This function can draw only 'SPACE',
'0'-'9', 'A'-'Z', '.' and '-'.
------------------------------------------------------------------------------
4. Put monochrome image data. <Main>
------------------------------------------------------------------------------
[Name]
_putpattern
[Syntax]
#include <graph.h>
void _putpattern( short x, short y, void *image, short action,
short fg, short bg ) ;
[Arguments]
x, y Coordinate of the left-upper corner at where the
monochrome image is put.
image Buffer in where monochrome image is stored.
action Logical writing mode.
fg Foreground color.
bg Background color.
[Return]
------
[Description]
Puts the monochrome image pattern stored in "image" in the rectangle
regtion whose left-upper corner is "x,y" on the graphic screen.
Specify the logical writing mode, monochrome image data in buffer and
image data on the screen are operated according to this command, in
"action". The logical writing mode is defined in "graph.h".
Specify the character color and the background color using palette
index number. Only image data is drawn if -32768 (0x8000) is
specified as the background color.
The image buffer size must be specified by word (2-byte) unit.
The buffer size (for monochrome image data) is calculated by the next
equation.
Size(byte) = ([WIDTH]+15)/16*2*[HEIGHT]+4
#include <graph.h>
#define Blue 1
#define White 7
return ;
}
------------------------------------------------------------------------------
5. Get monochrome image data. <Main>
------------------------------------------------------------------------------
[Name]
_getpattern
[Syntax]
#include <graph.h>
void _getpattern( short rsx, short rsy, short rex, short rey,
void *image, short color ) ;
[Arguments]
rsx, rsy, Coordinate of the rectangle region from wher the
rex, rey monochrome image data is got.
image Buffer in where the monochrome image data is stored.
color Color to be searched.
[Return]
------
[Description]
Gets the monochrome image data, whose color is same as the specified
color palette index number, in the specified rectangle region.
And stores it in the "image".
The buffer size muse be enough big to store the image data.
The buffer size is calculated by the next equation.
Size(byte) = ([WIDTH]+15)/16*2*[HEIGHT]+4
The maximum imaga size that is available for this function is 4K
bytes.
[Example]
The following program displays a cursor.
#include <graph.h>
#include <malloc.h>
void example( short rsx, short rsy, short ch_num, short OldColor,
short ForColor, short BakColor )
{
char *image ;
long image_size ;
short w, h ;
w = ch_num*8 ;
h = 16 ;
image_size = ( w+15 ) / 16 * 2 * h + 4 ;
if ( image_size > 4096L ) return ;
free( image ) ;
return ;
}
------------------------------------------------------------------------------
6. Draw a standard size string. <Main>
------------------------------------------------------------------------------
[Name]
gr_dispstr
[Syntax]
#include <graph.h>
void gr_dispstr( char *str, short cx, short cy,
short fg, short bg ) ;
[Arguments]
str Character string to be drawn.
cx, cy Coordinate of the left-upper corner at where the
character is drawn.
fg Character color.
bg Background color.
[Return]
------
[Description]
Draws character string (also Kanji character is available) on the
graphic screen.
Specify the character color and the background color using palette
index number. Only character is drawn if -32768 (0x8000) is specified
as the background color.
------------------------------------------------------------------------------
7. Draw a hex size string. <Main>
------------------------------------------------------------------------------
[Name]
gr_disp6str
[Syntax]
#include <graph.h>
void gr_disp6str( char *str, short cx, short cy,
short fg, short bg ) ;
[Arguments]
str Character string to be drawn.
cx, cy Coordinate of the left-upper corner at where the
character is drawn.
fg Character color.
bg Background color.
[Return]
------
[Description]
Draws large-size character (24x32 dots) string on the graphic screen.
Specify the character color and the background color using palette
index number. Only character is drawn if -32768 (0x8000) is specified
as the background color. This function can draw only 'SPACE',
'0'-'9', 'A'-'Z', '.' and '-'.
------------------------------------------------------------------------------
8. Copy image data. <Main>
------------------------------------------------------------------------------
[Name]
gr_bitblt
[Syntax]
#include <graph.h>
void gr_bitblt( short rsx, short rsy, short rex, short rey,
short cx, short cy ) ;
[Arguments]
rsx, rsy, Coordinate of the source rectangle.
rex, rey
cx, cy Destination (upper-left) coordinate.
[Return]
------
[Description]
Copys the image data in the specified rectangle region to the
specified destination on the screen.
------------------------------------------------------------------------------
9. Draw a quad size string. <Main>
------------------------------------------------------------------------------
[Name]
gr_disp4str
[Syntax]
#include <graph.h>
void gr_disp4str( char *str, short cx, short cy,
short fg, short bg ) ;
[Arguments]
str Character string to be drawn.
cx, cy Coordinate of the left-upper corner at where the
character is drawn.
fg Character color.
bg Background color.
[Return]
------
[Description]
Draws quad-size (16x32 dots) character string on the graphic screen.
Specify the character color and the background color using palette
index number. Only character is drawn if -32768 (0x8000) is specified
as the background color. This function can't draw 2-byte characters
such as Japanese Kanji characters. It can draw only half-size charac-
ters whose codes are 0x20 to 0x7F.
------------------------------------------------------------------------------
10. Draw a small size character. <Main>
------------------------------------------------------------------------------
[Name]
gr_displaysmlchar
[Syntax]
#include <graph.h>
void gr_displaysmlchar( int code, short cx, short cy,
short fg, short bg ) ;
[Arguments]
code Character code to be drawn.
cx, cy Coordinate of the left-upper corner at where the
character is drawn.
fg Character color.
bg Background color.
[Return]
------
[Description]
Draws small size (8x8 dots) character on the graphic screen.
Specify the character color and the background color using palette
index number. Only character is drawn if -32768 (0x8000) is specified
as the background color. This function draws only characters whose
codes are 0x20 - 0x5F. If lowercase character is specified, the
converted uppercase character is drawn instead.
[Name]
gr_dispsstr
[Syntax]
#include <graph.h>
void gr_dispsstr( char *str, short cx, short cy,
short fg, short bg ) ;
[Arguments]
str Character string to be drawn.
cx, cy Coordinate of the left-upper corner at where the
character is drawn.
fg Character color.
bg Background color.
[Return]
------
[Description]
Draws small size (8x8 dots) character string on the graphic screen.
Specify the character color and the background color using palette
index number. Only character is drawn if -32768 (0x8000) is specified
as the background color. This function draws only characters whose
codes are 0x20 - 0x5F. If lowercase character is specified, the
converted uppercase character is drawn instead.
[Name]
gr_displayfchar
[Syntax]
#include <graph.h>
void gr_displayfchar( unsigned int code, short cx, short cy,
short fg, short bg ) ;
[Arguments]
code Character code to be drawn.
cx, cy Coordinate of the left-upper corner at where the
character is drawn.
fg Character color.
bg Background color.
[Return]
------
[Description]
Draws a character which is specified by FANUC character code on the
graphic screen.
Specify the character color and the background color using palette
index number. Only character is drawn if -32768 (0x8000) is specified
as the background color.
------------------------------------------------------------------------------
13. Draw a FANUC character string. <Main>
------------------------------------------------------------------------------
[Name]
gr_dispfstr
[Syntax]
#include <graph.h>
void gr_dispfstr( unsigned int *code, unsigned int len,
short cx, short cy, short fg, short bg ) ;
[Arguments]
code Array of FANUC character code (0x0000 - 0xFFFF).
len Length of character string.
cx, cy Coordinate of the left-upper corner at where the
character is drawn.
fg Character color.
bg Background color.
[Return]
------
[Description]
Draws a character string which is specified by FANUC character code
on the graphic screen.
[Name]
gr_disp9ifchar
[Syntax]
#include <graph.h>
void gr_disp9ifchar( int code, short cx, short cy,
short fg, short bg) ;
[Arguments]
code Character code to be drawn.
cx, cy Coordinate of the left-upper corner at where the
character is drawn.
fg Character color.
bg Background color.
[Return]
------
[Description]
Draws 9-inch font character (16x25 dots or 32x25 dots for Kanji
character) on the graphic screen.
Specify the character color and the background color using palette
index number. Only character is drawn if -32768 (0x8000) is specified
as the background color.
[Remarks]
Specified character is drawn using FANUC character-generator and
FANUC Kanji-set.
------------------------------------------------------------------------------
15. Draw 9-inch font character string. <Main>
------------------------------------------------------------------------------
[Name]
gr_disp9ifstr
[Syntax]
#include <graph.h>
void gr_disp9ifstr( unsigned char *str, short cx, short cy,
short fg, short bg) ;
[Arguments]
str Character string to be drawn.
cx, cy Coordinate of the left-upper corner at where the
character is drawn.
fg Character color.
bg Background color.
[Return]
------
[Description]
Draws character string (also Kanji character is available) on the
graphic screen.
Specify the character color and the background color using palette
index number. Only character is drawn if -32768 (0x8000) is specified
as the background color.
[Remarks]
Specified character is drawn using FANUC character-generator and
FANUC Kanji-set.
------------------------------------------------------------------------------
16. Draw a line between specified two points. <Main>
------------------------------------------------------------------------------
[Name]
mmc_line_b
[Syntax]
#include <fgraph.h>
short mmc_line_b( short x1, short y1, short x2, short y2 ) ;
[Arguments]
x1, y1 View port coordinates of line start point.
x2, y2 View port coordinates of line end point.
[Return]
Returns non-0 value if successful, or 0 if any error.
[Description]
Draws a line between specified two points.
------------------------------------------------------------------------------
17. Draw a polyline. <Main>
------------------------------------------------------------------------------
[Name]
mmc_polyline
[Syntax]
#include <fgraph.h>
void mmc_polyline( const struct _xycoord *points, short numpoints ) ;
[Arguments]
points Array of view port coordinates of apexes.
numpoints Number of apexes of polyline.
[Return]
------
[Description]
Draws a polyline.
------------------------------------------------------------------------------
18. Draw a circle. <Main>
------------------------------------------------------------------------------
[Name]
mmc_circle_b
[Syntax]
#include <fgraph.h>
short mmc_circle_b( short control, short xc, short yc, short r ) ;
[Arguments]
control Control flag.
xc, yc View port coordinates of the circle center.
r Radius.
[Return]
Returns non-0 value if successful, or 0 if any error.
[Description]
Draws a circle.
Symbol Purpose
---------------+----------------------------------------------
_GFILLINTERIOR Fills inside of the object with the current
fill mask pattern.
_GBORDER Draws only border line, not fills inside.
------------------------------------------------------------------------------
19. Draw an ellipse. <Main>
------------------------------------------------------------------------------
[Name]
mmc_ellipse_b
[Syntax]
#include <fgraph.h>
short mmc_ellipse_b( short control, short xc, short yc, short xr,
short yr ) ;
[Arguments]
control Control flag.
xc, yc View port coordinate of the ellipse center.
xr X-directional radius.
yr Y-directional radius.
[Return]
Returns non-0 value if successful, or 0 if any error.
[Description]
Draws an ellipse.
Symbol Purpose
---------------+----------------------------------------------
_GFILLINTERIOR Fills inside of the object with the current
fill mask pattern.
_GBORDER Draws only border line, not fills inside.
------------------------------------------------------------------------------
20. Draw a pie figure. <Main>
------------------------------------------------------------------------------
[Name]
mmc_pie_b
[Syntax]
#include <fgraph.h>
short mmc_pie_b( short control, short xc, short yc, short xr,
short yr, short d1, short d2 ) ;
[Arguments]
control Control flag.
xc, yc View port coordinate of the circle center.
xr X-directional radius.
yr Y-directional radius.
d1 Angle of drawing start point (-3600..3600 [0.1 deg])
d2 Angle of drawing end point (-3600..3600 [0.1 deg])
[Return]
Returns non-0 value if successful, or 0 if any error.
[Description]
Draws a pie figure.
Symbol Purpose
---------------+----------------------------------------------
_GFILLINTERIOR Fills inside of the object with the current
fill mask pattern.
_GBORDER Draws only border line, not fills inside.
(Y) (Y)
| |
| |
90[deg]|<-----+ -270[deg]|<-----+
| | | |
| |0[deg] | |-360[deg]
----------------+----------------(X) ----------------+----------------(X)
180[deg]| | 360[deg] -180[deg]| | 0[deg]
| | | |
+----->|270[deg] +----->|-90[deg]
| |
| |
Pie figure is drawn counter clock wise (CCW) from the start point to
the end point. When the start point is same as the end point, pie
figure is not drawn but only a line which connects the circle center
and start/end point is drawn.
------------------------------------------------------------------------------
21. Draw an arc. <Main>
------------------------------------------------------------------------------
[Name]
mmc_arc_b
[Syntax]
#include <fgraph.h>
short mmc_arc_b( short xc, short yc, short xr, short yr, short d1,
short d2 ) ;
[Arguments]
xc, yc View port coordinate of the circle center.
xr X-directional radius.
yr Y-directional radius.
d1 Angle of drawing start point (-3600..3600 [0.1 deg])
d2 Angle of drawing end point (-3600..3600 [0.1 deg])
[Return]
Returns non-0 value if successful, or 0 if any error.
[Description]
Draws an arc.
(Y) (Y)
| |
| |
90[deg]|<-----+ -270[deg]|<-----+
| | | |
| |0[deg] | |-360[deg]
----------------+----------------(X) ----------------+----------------(X)
180[deg]| | 360[deg] -180[deg]| | 0[deg]
| | | |
+----->|270[deg] +----->|-90[deg]
| |
| |
Arc is drawn counter clock wise (CCW) from the start point to the end
point. When the start point is same as the end point, arc is not
drawn but only a pixel is drawn at the start/end point.
------------------------------------------------------------------------------
22. Get character in the specified area. <Main>
------------------------------------------------------------------------------
[Name]
mmc_gettext
[Syntax]
#include <fgraph.h>
short mmc_gettext( short x1, short y1, short x2, short y2,
_MCHRBUF *chr_buf ) ;
[Arguments]
x1,y1,x2,y2 Screen area (left-upper, right-lower)
chr_buf Buffer memory in where data are stored.
[Return]
0 Successful.
-1 Warning. (Out of screen)
2 Error. (No work memory)
[Description]
Reads characters in the specified screen area to the memory.
+----------------------------+
0 | Column size |
-----------------------------+
2 | Line size |
+----------------------------+
4 | 1st character - code | --+
+----------------------------+ +--- data for one character
6 | 1st character - attribute | --+
+----------------------------+
:
+----------------------------+
m | n-th character - code |
+----------------------------+
m+2 | n-th character - attribute |
+----------------------------+
If the specified area overruns the screen like below, SPACE character
and WHITE attribute is stored in the overruned region and "Warning"
is returned as result.
+---------------------------------+
|(1,1) |
| |
| screen |
| | specified area
| +---------------------------+
| |(x1,y1) |//////////|
| | |//////////|
| | |//////////|
| | (80,30)|//////////|
+----------------|----------------+//////////|
|///////////////////////////|
|////////////////////(x2,y2)|
+---------------------------+
[Name]
mmc_puttext
[Syntax]
#include <fgraph.h>
short mmc_puttext( short x, short y, _MCHRBUF *chr_buf ) ;
[Arguments]
x, y Start position to write.
chr_buf Buffer memory in where data are stored.
[Return]
0 Successful.
-1 Warning. (Out of screen)
2 Error. (No work memory)
[Description]
Writes characters stored on memory to the text screen.
This function writes character data on memory which has been read by
"mmc_gettext()" function. Specify screen area to write as left-upper
point of screen (Home position) is (1,1). If the specified area
overruns the screen, the overruned region is not written.
------------------------------------------------------------------------------
24. Get required byte size for getting character. <Main>
------------------------------------------------------------------------------
[Name]
mmc_textsize
[Syntax]
#include <fgraph.h>
short mmc_textsize( short x1, short y1, short x2, short y2 ) ;
[Arguments]
x1,y1,x2,y2 Screen area (left-upper, right-lower)
[Return]
Required byte size to read the specified area.
[Description]
Returns the required byte size to read the specified area.
The required byte size is calculated by the following formula.
Lists of Functions
~~~~~~~~~~~~~~~~~~
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
1.1 cnc_sysinfo Read CNC system information.
1.2 cnc_dwnstart Start output of NC program to be registered.
1.3 cnc_download Output NC program to be registered.
1.4 cnc_dwnend Stop output NC program to be registered.
1.5 cnc_vrfstart Start output NC program to be compared.
1.6 cnc_verify Output NC program to be compared.
1.7 cnc_vrfend Stop output NC program to be compared.
1.8 cnc_dncstart Start output NC program to be executed.
1.9 cnc_dnc Output NC program to be executed.
1.10 cnc_dncend Stop output NC program to be executed.
1.11 cnc_upstart Start input NC program.
1.12 cnc_upload Input NC program.
1.13 cnc_upend Stop input NC program.
1.14 cnc_search Search specified program.
1.15 cnc_delall Delete all programs.
1.16 cnc_delete Delete specified program.
1.17 cnc_rdprogdir Read program directory.
1.18 cnc_rdproginfo Read program information.
1.19 cnc_rdprgnum Read program number in executing.
1.20 cnc_rdseqnum Read sequence number in executing.
1.21 cnc_actf Read actual feed rate of controlled axes.
1.22 cnc_acts Read actual spindle speed.
1.23 cnc_absolute Read absolute position.
1.24 cnc_machine Read machine position.
1.25 cnc_relative Read relative position.
1.26 cnc_distance Read distance to go.
1.27 cnc_skip Read skipped position.
1.28 cnc_srvdelay Read servo delay amount.
1.29 cnc_accdecdly Read acceleration/deceleration delay amount.
1.30 cnc_rddynamic Read dynamic data.
1.31 cnc_statinfo Read CNC status information.
1.32 cnc_alarm Read alarm status.
1.33 cnc_rdalminfo Read alarm information.
1.34 cnc_rdtofs Read tool offset amount.
1.35 cnc_wrtofs Write tool offset amount.
1.36 cnc_rdtofsr Read tool offset amount (range specified).
1.37 cnc_wrtofsr Write tool offset amount (range specified).
1.38 cnc_rdzofs Read work origin offset.
1.39 cnc_wrzofs Write work origin offset.
1.40 cnc_rdzofsr Read work origin offset (range specified).
1.41 cnc_wrzofsr Write work origin offset (range specified).
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
1.42 cnc_rdparam Read parameter.
1.43 cnc_wrparam Write parameter.
1.44 cnc_rdparar Read parameters (range specified).
1.45 cnc_wrparas Write parameters (multiple output).
1.46 cnc_rdset Read setting parameter.
1.47 cnc_wrset Write setting parameter.
1.48 cnc_rdsetr Read setting parameters (range specified).
1.49 cnc_wrsets Write setting parameters (multiple output).
1.50 cnc_rdpitchr Read pitch error compensation data (range
specified).
1.51 cnc_wrpitchr Write pitch error compensation data (range
specified).
1.52 cnc_rdmacro Read custom macro variable.
1.53 cnc_wrmacro Write custom macro variable.
1.54 cnc_rdmacror Read custom macro variables (range specified).
1.55 cnc_wrmacror Write custom macro variables (range
specified).
1.56 cnc_rdpmacro Read P-code macro variable.
1.57 cnc_wrpmacro Write P-code macro variable.
1.58 cnc_rdpmacror Read P-code macro variables (range specified).
1.59 cnc_wrpmacror Write P-code macro variables (range
specified).
1.60 cnc_modal Read modal data.
1.61 cnc_diagnoss Read diagnostics data.
1.62 cnc_diagnosr Read diagnostics data (range specified).
1.63 cnc_adcnv Read A/D conversion data.
1.64 cnc_rdopmsg Read operator's message.
1.65 cnc_setpath Set path index (multi-path system).
1.66 cnc_getpath Get path index (multi-path system).
1.67 cnc_settimer Set calendar timer of CNC.
1.68 cnc_rdspload Read load information of serial spindle.
1.69 cnc_rdexecprog Read executing program.
1.70 cnc_rdmovrlap Read manual handle override amount.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
2.1 pmc_rdpmcrng Read arbitrary PMC data (range specified).
2.2 pmc_wrpmcrng Write arbitrary PMC data (range specified).
2.3 pmc_rdpcmsg Read PMC message.
--------------------------------------------------------------------------
Function Reference
~~~~~~~~~~~~~~~~~~
------------------------------------------------------------------------------
1.1 Read CNC system information. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_sysinfo
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_sysinfo( struct odbsys *buf ) ;
struct odbsys {
int dummy[2] ; /* Not used. */
char cnc_type[2] ; /* Kind of CNC (ASCII string). */
char mt_type[2] ; /* Kind of M/T/TT (ASCII string). */
char series[4] ; /* Series number (ASCII string). */
char version[4] ; /* Version number (ASCII string). */
char axes[2] ; /* Amount of controllable axes */
} ; /* (ASCII string). */
[Arguments]
buf Buffer in which system information is stored.
[Return]
EW_OK( 0) Successful.
[Description]
Reads system information such as kind of CNC (for example, "30" as
series name), kind of CNC system such as Machining(M) or Turning(T),
series and version number of CNC system software in ROM and an amount
of controllable axes.
Note that a null character ('\x00') is not added at the end of each
strings.
[Example]
The following informations are gotten by execution of this function
on FS30 (G001-01) system with 4 servo axes.
buf.cnc_type = "30"
buf.mt_type = " M"
buf.series = "G001"
buf.version = "0001"
buf.axes = "4 "
------------------------------------------------------------------------------
1.2 Start output of NC program to be registered. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_dwnstart
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_dwnstart( void ) ;
[Arguments]
------
[Return]
EW_OK( 0) Successful.
EW_PROT( 7) Tape memory of CNC is protected.
EW_BUSY(-1) Start command for output of NC program to be registered
has been rejected.
This code is returned if any of the following conditions
exists when this command is executed.
- The CNC is performing other command processing
(downloading, collating, uploading, or program number
list reading).
- Background editing is in progress or the MDI mode has
been entered.
- A P/S 000 or P/S 101 alarm condition has occurred.
[Description]
Requests CNC to start registering of NC program (downloading).
[Example]
See example of "Output NC program to be registered(cnc_download)".
------------------------------------------------------------------------------
1.3 Output NC program to be registered. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_download
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_download( char *data, short number ) ;
[Arguments]
data NC program data (ASCII string).
number Character number of NC program data (1 - 256).
[Return]
EW_OK( 0) Successful.
EW_FUNC( 1) The start-up procedure of CNC for registering NC
program has not been completed, or no start-up command
has been commanded.
EW_LENGTH( 2) Incorrect character number "number".
EW_DATA( 5) Incorrect NC program data. This code is returned under
one of following conditions.
- The same program number is already registered.
- A character which is unavailable for NC program is
detected.
- When TV check is effective, a block which includes
odd characters (including 'LF' at the end of the
block) is detected.
- No more programs can be registered because there is
no space for them.
EW_OVRFLOW( 8) No more NC program can be stored because tape memory
of CNC is full.
[Description]
Outputs NC program to be registered to CNC.
LF 0x0A ('\n').
Oxxxx Program number.
Mxx M code at the end of the program (M02,M30,
etc.).
'LF' must be placed at the top of the whole program, and '%' at the
end. Data before 'LF' at the top are ignored. Address 'O' and program
number must be placed in the program to be registered.
For example, to register a program such as
O1234 ;
G1 F0.3 W10. ;
M30 ;
%
send a following string using cnc_download function.
"\nO1234\nG1F0.3W10.\nM30\n%"
"\n"
"O1234\n"
"G1F0.3W10.\n"
"M30\n"
"%"
There is one buffer (256 bytes) between CNC and C library. It is used
as a ring.
Buffer size = 256 bytes
+--------------------------------------------------+
+-->| 1st output | 2nd output | ... | | --+
| +--------------------------------------------------+ |
| |
+----------------------------------------------------------+
When any data can not be output because registration process has
not been completed (i.e. the buffer is full), the C library waits
until it can be output. ERROR 5 and 8 may be returned late because
NC program is sent to CNC via buffers. That is, the return code
of an output process may be one of it several times before.
Moreover, return codes of several output before the last one may
be returned by "Stop output NC program to be registered(cnc_dwnend)".
[Example]
The following program registers the next NC program to CNC.
O1234 ;
M3 S1200 ;
G0 Z0 ;
G0 X0 Y0 ;
G1 F500 X120. Y-30. ;
M30 ;
#include <data.h>
#include <fwindow.h>
[Name]
cnc_dwnend
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_dwnend( void ) ;
[Arguments]
------
[Return]
EW_OK( 0) Successful.
EW_FUNC( 1) The start-up procedure of CNC for registering NC
program has not been completed, or no start-up command
has been commanded.
EW_DATA( 5) Incorrect NC program data in previous output. This code
is returned under one of following conditions.
- The same program number is already registered.
- A character which is unavailable for NC program is
detected.
- When TV check is effective, a block which includes
odd characters (including 'LF' at the end of the
block) is detected.
- No more programs can be registered because there is
no space for them.
EW_OVRFLOW( 8) NC programs which have been output previously could
not registered because tape memory of CNC is full.
[Description]
Notices the end of NC program registration to CNC.
'%' must be output as NC program data before calling this function.
[Example]
See example of "Output NC program to be registered(cnc_download)".
------------------------------------------------------------------------------
1.5 Start output NC program to be compared. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_vrfstart
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_vrfstart( void ) ;
[Arguments]
------
[Return]
EW_OK( 0) Successful.
EW_BUSY(-1) Start command for output of NC program to be compared
has been rejected.
This code is returned if any of the following conditions
[Description]
Requests CNC to start comparing of NC program.
[Example]
See example of "Output NC program to be compared(cnc_verify)".
------------------------------------------------------------------------------
1.6 Output NC program to be compared. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_verify
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_verify( char *data, int number ) ;
[Arguments]
data NC program data (ASCII string).
number Character number of NC program data (1 - 256).
[Return]
EW_OK( 0) Successful.
EW_FUNC( 1) The start-up procedure of CNC for comparing NC program
has not been completed, or no start-up command has been
commanded.
EW_LENGTH( 2) Incorrect character number "number".
EW_DATA( 5) Incorrect NC program data. This code is returned under
one of following conditions.
- Any difference has been detected during comparing
process.
- A CNC-side program to be compared has been selected in
foreground processing.
- A character which is unavailable for NC program is
detected.
- When TV check is effective, a block which includes
odd characters (including 'LF' at the end of the
block) is detected.
[Description]
Outputs NC program to be compared with already registered one to CNC.
When any data can not be output because comparing process has not been
completed (i.e. the buffer is full), the C library waits until it can
be output. EW_DATA may be returned late because NC program is sent to
CNC via buffers. That is, the return code of an output process may be
one of it several times before.
Moreover, return codes of several output before the last one may be
returned by "Stop output NC program to be compared(cnc_vrfend)".
[Example]
The following program compares the next NC program and "O1234" which
is already registered in CNC.
O1234 ;
M3 S1200 ;
G0 Z0 ;
G0 X0 Y0 ;
G1 F500 X120. Y-30. ;
M30 ;
#include <data.h>
#include <fwindow.h>
[Name]
cnc_vrfend
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_vrfend( void ) ;
[Arguments]
------
[Return]
EW_OK( 0) Successful.
EW_FUNC( 1) The start-up procedure of CNC for comparing NC program
has not been completed, or no start-up command has been
commanded.
EW_DATA( 5) The previously output NC program data is incorrect. This
code is returned under one of following conditions.
- Any difference has been detected during comparing
process.
- A CNC-side program to be compared has been selected in
foreground processing.
- A character which is unavailable for NC program is
detected.
- When TV check is effective, a block which includes
odd characters (including 'LF' at the end of the
block) is detected.
[Description]
Notices the end of comparison of NC program to CNC.
[Example]
See example of "Output NC program to be compared(cnc_verify)".
------------------------------------------------------------------------------
1.8 Start output NC program to be executed. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_dncstart
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_dncstart( void ) ;
[Arguments]
------
[Return]
EW_OK( 0) Successful.
EW_BUSY(-1) Start command for output of NC program to be executed
has been rejected.
This code is returned under one of following conditions.
(7) Reset CNC when the program is completed (i.e., the M-code which
means the end of the program is detected.) [LADDER]
[Example]
See example of "Output NC program to be executed(cnc_dnc)".
------------------------------------------------------------------------------
1.9 Output NC program to be executed. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_dnc
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_dnc( char *data, short number ) ;
[Arguments]
data NC program data (ASCII string).
number Character number of NC program data (1 - 256).
[Return]
EW_OK( 0) Successful.
EW_FUNC( 1) The start-up procedure of CNC for executing NC program
has not been completed, or no start-up command has been
commanded.
EW_LENGTH( 2) Incorrect character number "number".
EW_DATA( 5) Incorrect NC program data.
EW_RESET(-2) The CNC has been reset.
In this case, stop outputting of NC command data to be
executed and perform the end operation of outputting
of NC command.
[Description]
Outputs NC command data to be directly executed to CNC (for DNC
operation).
LF 0x0A ('\n').
Mxx M code at the end of the DNC operation (M02,
M30,etc.).
'LF' must be placed at the top of the whole NC commands, and '%' at
the end.
'LF's are added after each NC commands.
For example, to execute commands such as
M3 S2000 ;
T14 ;
G0 X10. ;
G0 Z-5. ;
M30 ;
send a following string using cnc_dnc function.
cnc_dnc( "\nM3S2000\nT14\nG0X10.\nG0Z-5.\nM30\n%", 32 ) ;
cnc_dnc( "\n", 1 ) ;
cnc_dnc( "M3S2000\n", 8 ) ;
cnc_dnc( "T14\n", 4 ) ;
cnc_dnc( "G0X10.\n", 7 ) ;
cnc_dnc( "G0Z-5.\n", 7 ) ;
cnc_dnc( "M30\n", 4 ) ;
cnc_dnc( "%", 1 ) ;
There is one buffer (256 bytes) between CNC and C library. It is used
as a ring.
When any data can not be output because operating process has not been
completed (i.e. the buffer is full), the C library waits until it can
be output. EW_DATA may be returned late because NC program is sent to
CNC via buffers. That is, the return code of an output process may be
one of it several times before.
Moreover, return codes of several output before the last one may
be returned by "Stop output NC program to be executed(cnc_dncend)".
(2) Store the above program in the tape memory of CNC unit.
(It is possible to store compiled code of program in ROM using
Macro Compiler.)
M3 S1500 ;
G28 U0 W0 ;
T0101 ;
G0 X35. Z-10. ;
M30 ;
#include <data.h>
#include <fwindow.h>
[Name]
cnc_dncend
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_dncend( void ) ;
[Arguments]
------
[Return]
EW_OK( 0) Successful.
EW_FUNC( 1) The start-up procedure of CNC for executing NC program
has not been completed, or no start-up command has been
commanded.
EW_DATA( 5) Incorrect NC program data.
EW_RESET(-2) The CNC has been reset.
[Description]
Notices the end of DNC operation to CNC.
Execute this stopping command after the CNC's operation has been
completed and reset. If this command is executed during CNC is
operating, the function-call waits until the end of operation and
resetting. Check "OP" signal(F000#7) to find whether CNC has been
reset or not. When "OP" signal is "0", CNC is has been reset.
[Example]
See example of "Output NC program to be executed(cnc_dnc)".
------------------------------------------------------------------------------
1.11 Start input NC program. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_upstart
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_upstart( long number ) ;
[Arguments]
number Program number.
[Return]
EW_OK( 0) Successful.
EW_DATA( 5) The specified NC program is not registered in CNC.
EW_PROT( 7) Tape memory of CNC is protected.
EW_BUSY(-1) Start command for input of NC program to be uploaded
has been rejected.
This code is returned under one of following
conditions.
- CNC is executing other requested command
(downloading, comparing, uploading or reading
program directory).
- An NC program is running (automatic operation signal
OP<F000#7> is on).
- Background editing is in progress or the MDI mode has
been selected.
- A P/S 000 or P/S 101 alarm condition has occurred.
[Description]
Requests CNC to start reading of NC program (uploading).
[Example]
See example of "Input NC program(cnc_upload)".
------------------------------------------------------------------------------
1.12 Input NC program. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_upload
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_upload( struct odbup *buf, short *number ) ;
struct odbup {
short dummy[2] ; /* Not used. */
char data[N] ; /* NC program data (ASCII string). */
} ; /* N: max 256 */
[Arguments]
buf Buffer in which NC program data are stored.
number Size of the above buffer, amount of characters
included in input NC command data characters.
[Return]
EW_OK( 0) Successful.
EW_FUNC( 1) The start-up procedure of CNC for reading NC program
has not been completed, or no start-up command has
been commanded.
EW_LENGTH( 2) Incorrect buffer size "number".
[Description]
Inputs contents of NC program specified by "cnc_upstart" function from
CNC.
When any data can not be input because transfer process has not been
completed (i.e. the buffer is empty), the C library waits until any
data are written in the buffer
Format of input data
~~~~~~~~~~~~~~~~~~~~
NC program which is read from CNC is a string composed of ASCII
characters as following format.
LF 0x0A ('\n').
Oxxxx Program number.
Mxx M code at the end of the program (M02,M30,
etc.).
O1234 ;
G1 F0.3 W10. ;
M30 ;
%
And in case that the buffer size is less than 24 bytes, you will get
the following strings.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#define BUFSIZE 40
/* prgnum is NC program number to be read. */
short example( long prgnum )
{
char buf[BUFSIZE+4] ;
short ret, number ;
ret = cnc_upstart( prgnum ) ;
if ( ret ) return ( ret ) ;
for (;;) {
number = BUFSIZE - 1 ;
ret = cnc_upload( (struct odbup *)(&buf), &number ) ;
if ( ret ) {
cnc_upend() ;
return ( ret ) ;
}
buf[4+number] = '\x00' ;
printf( "%s", &buf[4] ) ;
if ( buf[4+number-1] == '%' ) break ;
}
putchar( '\n' ) ;
ret = cnc_upend() ;
return ( ret ) ;
}
------------------------------------------------------------------------------
1.13 Stop input NC program. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_upend
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_upend( void ) ;
[Arguments]
------
[Return]
EW_OK( 0) Successful.
EW_FUNC( 1) The start-up procedure of CNC for reading NC program
has not been completed, or no start-up command has been
commanded.
[Description]
Notices the end of NC program uploading to CNC.
[Example]
See example of "Input NC program(cnc_upload)".
------------------------------------------------------------------------------
1.14 Search specified program. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_search
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_search( long number ) ;
[Arguments]
number Program number.
[Return]
EW_OK( 0) Successful.
EW_DATA( 5) The specified NC program is not registered in CNC.
EW_PROT( 7) Tape memory of CNC is protected.
EW_BUSY(-1) The program search command was rejected.
This code is returned if any of the following conditions
exists when this command is executed.
- The CNC is performing other window command processing
(downloading, collating, uploading, or program number
list reading).
- In the EDIT or memory mode, the automatic operation
signal OP<F000 #7> is on.
- In the EDIT or memory mode, a P/S 000 or P/S 101 alarm
[Description]
Searches the NC program already registered in CNC.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
/* num is program number to be searched. */
void example( long num )
{
short ret ;
ret = cnc_search( num ) ;
switch ( ret ) {
case 0:
printf( "PROGRAM O%d has been searched.\n", num ) ;
break ;
case 5:
printf( "PROGRAM O%d doesn't exist.\n", num ) ;
break ;
case 7:
printf( "PROTECTED.\n" ) ;
break ;
case -1:
printf( "REJECTED.\n" ) ;
break ;
}
}
------------------------------------------------------------------------------
1.15 Delete all programs. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_delall
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_delall( void ) ;
[Arguments]
------
[Return]
EW_OK( 0) Successful.
EW_PROT( 7) Tape memory of CNC is protected, or the target program
is protected.
EW_BUSY(-1) In the CNC, the all-program delete command was rejected.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_delete
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_delete( long number ) ;
[Arguments]
number Program number.
[Return]
EW_OK( 0) Successful.
EW_DATA( 5) The specified NC program is not registered in CNC.
EW_PROT( 7) Tape memory of CNC is protected, or the target program
is protected.
EW_BUSY(-1) In the CNC, the specified-program delete command was
rejected.
This code is returned if any of the following conditions
[Description]
Deletes the specified NC program registered in CNC.
If the specified program is used for the current automatic operation,
it can't be deleted.
Specify the program number of NC program to be deleted in "number"
with binary format.
[Example]
The following program deletes the program whose program number is same
as specified one, and displays the result.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_rdprogdir
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdprogdir( short type, long datano_s, long datano_e,
short length, struct prgdir *buf ) ;
struct prgdir {
char prg_data[N] ; /* Contents of directory (ASCII */
} ; /* string). N: max 256 */
[Arguments]
type Format of program list (0,1,2).
datano_s Start program number to be read.
datano_e End program number to be read.
length Size of the following buffer for the program
directory.
buf Buffer in which the program directory list is stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect buffer size "length".
EW_NUMBER( 3) The specified type is invalid.
EW_DATA( 5) The specified program number is invalid.
EW-BUSY(-1) In the CNC, read processing for program number list data
was rejected.
This code is returned if any of the following conditions
LF 0x0A ('\n')
Oxxxx Program number. This is a ASCII string
without the leading '0' of numeric
part sorted in numeric order. ("O1" -
"O9999")
CHAR_NUMBER Character number of the program.
This is a ASCII string without the
leading '0'.
The number is raised to 80-character
unit.
COMMENT The comment which is written just
after the program number is stored.
The maximum character number of the
comment body is 48. (50 for the body
and the before and the behind
parentheses.)
Only beginning 48 characters are
stored for the comment which is longer
than 48 characters.
If the program has no comment, only
parentheses ("()") are stored.
[Example]
The following program reads the registration information of NC program
included specified by the arguments, and displays program number list.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <string.h>
#define BUFSIZE 256
[Name]
cnc_rdproginfo
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdproginfo( short type, short length, struct odbnc *buf ) ;
struct odbnc {
union {
struct {
short reg_prg ; /* Amount of registered programs. */
short unreg_prg ;/* Amount of available programs.*/
long used_mem ; /* Character size of used memory.*/
long unused_mem ;/* Character size of unused */
} bin ; /* memory. */
char asc[31] ; /* Buffer for ASCII string format. */
} u ;
} ;
[Arguments]
type Data type ( =0(binary), 1(ASCII) ).
length Data block length ( =16(binary), 35(ASCII) ).
buf Buffer in which the program information is stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect data type "type".
[Description]
Reads the management data of NC programs already registered in CNC.
This function returns these data with binary format or ASCII string
format. These informations are same as ones which are displayed in
PROGRAM/LIB screen (in EDIT mode) of CNC. Specify arguments as follows
for each formats.
Format type length
---------------+-------+-------
binary 0 16
ASCII 1 35
Format of input data
~~~~~~~~~~~~~~~~~~~~
- type=0
Each data are stored in each members of the structure with binary
format.
- type=1
ASCII strings are stored in "buf.u.asc" with following format.
% LF d1 LF d2 LF d3 LF d4 LF %
LF 0x0A ('\n').
d1 Amount of registered programs.
d2 Amount of available programs.
d3 Character number of used memory.
d4 Character number of unused memory.
d1 - d4 are ASCII strings without the leading '0'.
[Example]
The following program reads the management data of NC program, and
displays them.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_rdprgnum
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdprgnum( struct odbpro *buf ) ;
struct odbpro {
short dummy[2] ; /* Not used. */
long data ; /* Program number in executing. */
long mdata ; /* Program number of the main
program. */
} ;
[Arguments]
buf Buffer in which program numbers are stored.
[Return]
EW_OK( 0) Successful.
[Description]
Reads program number of the program which is being currently executed
in CNC.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_rdseqnum
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdseqnum( struct odbact *buf ) ;
struct odbact {
short dummy[2] ; /* Not used. */
long data ; /* Sequence number in executing. */
} ;
[Arguments]
buf Buffer in which sequence number is stored.
[Return]
EW_OK( 0) Successful.
EW_BUSY(-1) It was impossible to read the sequence number of an NC
program being executed because the CNC was updating that
sequence number.
[Description]
Reads the sequence number of the NC program which is being currently
executed in CNC.
If the NC program has no sequence numbers in its all blocks, the
sequence number of the last executed block is read.
This function is used for watch the block being executed or the
current process by the application program, or only displaying the
current sequence number.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
O1234 ;
N10 M3 S1500 ;
N20 T12 ;
N30 G0 X110. ;
N40 ...
------------------------------------------------------------------------------
1.21 Read actual feed rate of controlled axes. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_actf
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_actf( struct odbact *buf ) ;
struct odbact {
short dummy[2] ; /* Not used. */
long data ; /* Actual feed rate (F). */
} ;
[Arguments]
buf Buffer in which the actual feed rate (F) is stored.
[Return]
EW_OK( 0) Successful.
EW_BUSY(-1) It was impossible to read the actual feed rate of a
controlled axis because the CNC was updating that actual
feed rate.
[Description]
Reads the actual feed rate of the controlled axes of CNC.
This function is used for display the actual feed rate of the
controlled axes of CNC by the application program, etc.
The actual feed rate data is stored in "buf.data" with unsigned binary
format. The unit of the actual feed rate is as follows.
mm input 1 [mm/min]
inch input 0.01 [inch/min]
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
O1234 ;
N10 G98 F1200 ;
N20 G1 U10. W200.
N30 ...
------------------------------------------------------------------------------
1.22 Read actual spindle speed. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_acts
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_acts( struct odbact *buf ) ;
struct odbact {
short dummy[2] ; /* Not used. */
long data ; /* Actual spindle speed. */
} ;
[Arguments]
buf Buffer in which the actual spindle speed is stored.
[Return]
EW_OK( 0) Successful.
[Description]
Reads the actual rotational speed of the spindle connected to CNC.
[Example]
The following program displays "CURRENT S=2470" while the actual
rotational speed of the main spindle is 2470.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_absolute
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_absolute( short axis, short length, struct iodbaxis *buf ) ;
struct iodbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Absolute position data of */
} ; /* controlled axis. */
/* N is a maximum controlled axis number.*/
[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
length Data block length ( =4+4*(Number of axes for which data
is to be read) ).
buf Buffer in which the absolute position data are stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled
axes) has been specified.
EW_BUSY(-1) It was impossible to read the absolute position data for
IS-B IS-C
-----------------------+---------------+---------------
Linear axis(mm input) 0.001 [mm] 0.0001 [mm]
Linear axis(inch input) 0.0001 [inch] 0.00001 [inch]
Rotation axis 0.001 [deg] 0.0001 [deg]
[Example]
The following program displays
1: 120005
2: -50119
3: 80
while the absolute position data for each axes are
The 1st axis 120.005
The 2nd axis -50.119
The 3rd axis 0.080
in 3-axis system.
(in case of "mm input" and "IS-B".)
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
void example( void )
{
struct iodbaxis buf ;
cnc_absolute( -1, 4+4*3, &buf ) ;
printf( "1:%8ld\n2:%8ld\n3:%8ld\n", buf.data[0], buf.data[1],
buf.data[2] ) ;
}
------------------------------------------------------------------------------
1.24 Read machine position. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_machine
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_machine( short axis, short length, struct iodbaxis *buf ) ;
struct iodbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Machine position data of */
} ; /* controlled axis. */
/* N is a maximum controlled axis number.*/
[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
length Data block length ( =4+4*(Number of axes for which data
is to be read) ).
buf Buffer in which the machine position data are stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled
axes) has been specified.
EW_BUSY(-1) It was impossible to read the machine position data for
a controlled axis because the CNC was updating that
machine position data.
[Description]
Reads the machine position data of the controlled axis of CNC.
IS-B IS-C
-----------------------+---------------+---------------
Linear axis(mm output) 0.001 [mm] 0.0001 [mm]
Linear axis(inch output)0.0001 [inch] 0.00001 [inch]
Rotation axis 0.001 [deg] 0.0001 [deg]
[Example]
The following program displays "MACHINE 2: -265593" while the machine
position data of the 2nd axis is -26.5593.
(in case of "inch output" and "IS-B".)
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_relative
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_relative( short axis, short length, struct iodbaxis *buf ) ;
struct iodbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Relative position data of */
} ; /* controlled axis. */
/* N is a maximum controlled axis number.*/
[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled
axes) has been specified.
EW_BUSY(-1) It was impossible to read the relative position data for
IS-B IS-C
-----------------------+---------------+---------------
Linear axis(mm input) 0.001 [mm] 0.0001 [mm]
Linear axis(inch input) 0.0001 [inch] 0.00001 [inch]
Rotation axis 0.001 [deg] 0.0001 [deg]
[Example]
The following program displays "RELATIVE 4: 900051" while the
relative position data of the 4th axis(rotation axis) is 90.0051.
(in case of "IS-C".)
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_distance
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_distance( short axis, short length, struct iodbaxis *buf ) ;
struct iodbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Amount of distance to go of */
} ; /* controlled axis. */
/* N is a maximum controlled axis number.*/
[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
length Data block length ( =4+4*(Number of axes for which data
is to be read) ).
buf Buffer in which the amounts of distance to go are
stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled
axes) has been specified.
EW_BUSY(-1) It was impossible to read data about the
distance-yet-to-go of a controlled axis because the CNC
was updating that data.
[Description]
Reads the amount of distance to go of the controlled axis of CNC.
This amount of distance to go is same as one which is displayed on
the current position screen of CNC.
[Name]
cnc_skip
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_skip( short axis, short length, struct iodbaxis *buf ) ;
struct iodbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Skipped position data of */
} ; /* controlled axis. */
/* N is a maximum controlled axis number.*/
[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled
axes) has been specified.
EW_BUSY(-1) It was impossible to read data about a skipped position
for a controlled axis because the CNC was updating that
data.
[Description]
Reads the absolute position data of the controlled axis at the
position where the machine has stopped by "ON" of the skip signal
during the CNC was executing the skip command (G31) block.
The skipped position of the axis which has not been completed skip
operation is undefined.
[Example]
The following program displays the skipped position of the 1st and 2nd
axes.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_srvdelay
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_srvdelay( short axis, short length, struct iodbaxis *buf ) ;
struct iodbaxis {
short dummy ; /* Not used. */
hort type ; /* Axis number. */
long data[N] ; /* Servo delay amount of */
} ; /* controlled axis. */
/* N is a maximum controlled axis number.*/
[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled
axes) has been specified.
EW_BUSY(-1) It was impossible to read the servo delay amount for a
controlled axis because the CNC was updating that servo
delay amount.
[Description]
Reads the difference between the commanded position and the actual
servo position of the CNC's controlled axis, i.e. the servo delay
amount.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_accdecdly
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_accdecdly( short axis, short length, struct iodbaxis *buf ) ;
struct iodbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Acceleration/deceleration delay */
} ; /* amount of controlled axis. */
/* N is a maximum controlled axis number.*/
[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled
axes) has been specified.
EW_BUSY(-1) It was impossible to read the acceleration/deceleration
delay amount for a controlled axis because the CNC was
updating that acceleration/deceleration delay amount.
[Description]
Reads the difference between the position commanded by the program and
the one processed by acceleration/deceleration procedure of the CNC's
controlled axis, i.e. the acceleration/deceleration delay amount.
[Example]
The following program displays the acceleration/deceleration delay
amount of all axes (amount of axes = MAX).
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_rddynamic
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rddynamic( short axis, short length, struct odbdy *buf ) ;
struct odbdy {
short dummy ; /* Not used. */
short axis ; /* Axis number. */
short alarm ; /* Alarm status. */
long prgnum ; /* Program number in executing. */
long prgmnum ; /* Program number of the main prog. */
long seqnum ; /* Sequence number. */
long actf ; /* Actual feed rate. */
long acts ; /* Actual spindle speed. */
union {
struct {
long absolute[32] ; /* Absolute position */
/* data of controlled*/
/* axis. */
long machine[32] ; /* Machine position */
/* data of controlled*/
/* axis. */
long relative[32] ; /* Relative position */
/* data of controlled*/
/* axis. */
long distance[32] ; /* Amount of distance*/
/* to go of */
/* controlled axis. */
} faxis ; /* For all axes. */
struct {
long absolute ; /* Absolute position */
/* data of controlled*/
/* axis. */
long machine ; /* Machine position */
/* data of controlled*/
/* axis. */
long relative ; /* Relative position */
/* data of controlled*/
/* axis. */
long distance ; /* Amount of distance*/
/* to go of */
/* controlled axis. */
} oaxis ; /* For one axis. */
} pos ;
} ;
[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled
axes) has been specified.
EW_BUSY(-1) It was impossible to read dynamic data because the CNC
was updating part of that data.
[Description]
Reads various data which are changing every second while NC program is
executing at the same time.
This function is used for getting data to display the current position
screen or the monitoring screen, etc.
Function used
for reading
Data individually
-----------------------------------------------+--------------
Alarm status cnc_alarm
Program number in executing cnc_rdprgnum
Program number of the main program cnc_rdprgnum
Sequence number cnc_rdseqnum
Actual feed rate cnc_actf
Actual spindle speed cnc_acts
Absolute position data of controlled axis cnc_absolute
Machine position data of controlled axis cnc_machine
Relative position data of controlled axis cnc_relative
Amount of distance to go of controlled axis cnc_distance
The formats of each data are same as "Function used for reading
individually". Refer each functions for formats of data, etc.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_statinfo
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_statinfo( struct odbst *buf ) ;
struct odbst {
short dummy[2]; /* Not used */
short aut; /* OPERATION mode selection */
short run; /* Status of automatic operation */
short motion; /* Status of axis movement,dwell */
short mstb; /* Status of M,S,T,B function */
short emergency; /* Status of emergency stop, rest */
short alarm; /* Status of alarm */
short edit; /* Status of program editing */
} ;
[Arguments]
buf Buffer in which the status informations are stored.
[Return]
EW_OK( 0) Successful.
[Description]
Reads the status informations of CNC which are displayed in the bottom
of the NC's screen.
[Name]
cnc_alarm
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_alarm( struct odbapb *buf ) ;
struct odbapb {
short dummy[2] ; /* Not used. */
short data ; /* Alarm status. */
} ;
[Arguments]
buf Buffer in which the alarm status is stored.
[Return]
EW_OK( 0) Successful.
[Description]
Reads the alarm status of CNC.
buf.data
bit0 The parameter write switch is on. (SW)
bit1 A parameter that requires turning off the
power was input. (PW)
bit2 I/O error (IO)
bit3 Foreground P/S (PS)
bit4 Overtravel/external data input error (OT)
bit5 Overheat (OH)
bit6 Servo alarm (SV)
bit7 Data input/output error (SR)
bit8 Macro alarm (MC)
bit9 Spindle alarm (SP)
bit10 OT alarm that will not lead to a PS alarm (DS)
bit11 Alarm related to malfunction prevention (IE)
bit12 Background P/S (BG)
bit13 Synchronization error too high (SN)
bit14 Reserved
bit15 External alarm message (EX)
[Name]
cnc_rdalminfo
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdalminfo( short type, short alm_type, short length,
struct alminfo *buf ) ;
struct alminfo {
union {
struct {
struct {
long axis ; /* Axis information. */
short alm_no ; /* Alarm number. */
} alm[N] ; /* N is number of messages to be read. */
long data_end ;
} alm1 ;
struct {
struct {
long axis ; /* Axis information. */
short alm_no ; /* Alarm number. */
short msg_len ; /* Message length. */
char alm_msg[32] ; /* Alarm message. */
} alm[N] ; /* N is number of messages to be read. */
long data_end ;
}alm2 ;
} u ;
} ;
[Arguments]
type Data format ( =0(without message), 1(with message) ).
alm_type Kind of alarm ( =0,..,31 ).
length Data block length ( =4+6*N(without message),
4+40*N(with message) ).
buf Buffer in which the alarm information is stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect data format type "type".
EW_DATA( 5) Incorrect kind of alarm "alm_type".
[Description]
Reads the detail informations of currently arising CNC alarms.
This function can't read the alarm mesages (numbers 1000 to 1999)
issued by PMC.
------------------------------------------------------------------------------
1.34 Read tool offset amount. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_rdtofs
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdtofs( short number, short type, short length,
struct odbtool *buf ) ;
struct odbtool {
short datano ; /* Offset number. */
short type ; /* Offset type. */
long data ; /* Offset data. */
} ;
[Arguments]
number Offset number.
type Offset type.
length Data block length ( =8 ).
buf Buffer in which the offset amount is stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect offset number "number".
(This return code is returned in case that any value
except 1,..,(maximum number of offset) was specified
in offset number "number".
EW_ATTRIB( 4) Incorrect offset type "type".
EW_NOOPT( 6) There are no additional tool offset options required
for the specified offset number to be read.
Related options (M Series)
- Number of tool
compensation
values (32)/64/99/200/400/499/999 sets
- Tool compensation memory (A)/B/C
Related options (T Series)
- Number of tool
compensation
values (32)/64/99/200/400/499/999 sets
- Tool-nose radius compensation
- Tool geometry compensation and wear
compensation
- Y-axis offset
Marked item by "()" is the basic function.
EW_BUSY(-1) It has been failed to read tool offset amount because
the other application program has already started
writing tool offset amount.
[Description]
Reads the tool offset amount stored in the CNC.
Lathe Series
type Kind of offset amount
-------+----------------------
0 X-axis wear offset amount
1 X-axis geometry offset amount
2 Z-axis wear offset amount
3 Z-axis geometry offset amount
4 Tool-nose radius wear offset amount
5 Tool-nose radius geometry offset amount
6 Virtual tool tip direction
7 Virtual tool tip direction
8 Y-axis wear offset amount
9 Y-axis geometry offset amount
If there is no tool geometry compensation option, specify a wear
compensation option.
The offset amount is stored in "buf.data" with signed binary format.
(The negative value is represented as 2's complement.)
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
/* tidx is tool index. */
void example( short tidx )
{
struct odbtool buf ;
short ret ;
ret = cnc_rdtofs( tidx, 0, 8, &buf ) ;
if ( !ret ) printf( "X(%d) = %ld\n", tidx, buf.data ) ;
ret = cnc_rdtofs( tidx, 2, 8, &buf ) ;
if ( !ret ) printf( "Z(%d) = %ld\n", tidx, buf.data ) ;
ret = cnc_rdtofs( tidx, 8, 8, &buf ) ;
if ( !ret ) printf( "Y(%d) = %ld\n", tidx, buf.data ) ;
}
------------------------------------------------------------------------------
1.35 Write tool offset amount. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_wrtofs
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrtofs( short number, short type, short length, long data ) ;
[Arguments]
number Offset number.
type Offset type.
length Data block length ( =8 ).
data Offset data.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect offset number "number".
(This return code is returned in case that any value
except 1,..,(maximum number of offset) was specified
in offset number "number".
EW_ATTRIB( 4) Incorrect offset type "type".
EW_NOOPT( 6) There are no additional tool offset options required
for the specified offset number to be written. (See
"Read tool offset amount(cnc_rdtofs)" for details.)
EW_BUSY(-1) An attempt was made to execute this command when other
window processing of a low-speed type was in progress.
Execute the command after the window processing has
ended.
[Description]
Alters the tool offset amount stored in the CNC.
Lathe Series
type Kind of offset amount
-------+------------------------------------------------------
0 X-axis wear offset amount
1 X-axis geometry offset amount
2 Z-axis wear offset amount
3 Z-axis geometry offset amount
4 Tool-nose radius wear offset amount
5 Tool-nose radius geometry offset amount
6 Virtual tool tip direction
7 Virtual tool tip direction
8 Y-axis wear offset amount
9 Y-axis geometry offset amount
If there is no tool geometry compensation option, specify a wear
compensation option.
Store the offset amount in "buf.data" with signed binary format.
(The negative value is represented as 2's complement.)
#include <data.h>
#include <fwindow.h>
}
------------------------------------------------------------------------------
1.36 Read tool offset amount (range specified). <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_rdtofsr
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdtofsr( short s_number, short type, short e_number,
short length, struct iodbto *buf ) ;
struct iodbto {
short datano_s ; /* Start offset number. */
short type ; /* Offset type. */
short datano_e ; /* End offset number. */
union {
long m_ofs[N] ; /* M Series individual. */
long m_ofs_a[N] ; /* M Series Memory A all. */
long m_ofs_b[2*N] ; /* M Series Memory B all. */
long m_ofs_c[4*N] ; /* M Series Memory C all. */
short t_tip[N] ; /* T Series individual, */
/* direction of imaginary */
/* tool nose. */
long t_ofs[N] ; /* T Series individual. */
struct {
short tip ;
long data[4] ;
} t_ofs_a[N] ; /* T Series Memory A all. */
struct {
short tip ;
long data[8] ;
} t_ofs_b[N] ; /* T Series Memory B all. */
} u ;
} ;
/* N is number of the offset amounts to be read. */
[Arguments]
s_number Start offset number.
type Offset type.
e_number End offset number.
length Data block length.
buf Buffer in which the offset amounts are stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect offset number "s_number" or "e_number".
(This return code is returned in case that any value
except 1,..,(maximum number of offset) was specified
in offset number "s_number" or "e_number".
EW_ATTRIB( 4) Incorrect offset type "type".
EW_NOOPT( 6) There are no additional tool offset options required
for the specified offset number to be read. (See
"Read tool offset amount(cnc_rdtofs)" for details.)
EW_BUSY(-1) It was impossible to read a tool offset amount because
a command from another application program to write the
tool offset amount was already being executed.
[Description]
Reads the tool offset amount stored in the CNC within the specified
range.
Specify the start offset number in "s_number" and the end one in
"e_number". Specify the kind of offset amount to be read in "type".
The combinations of the value specified in "type", the data block
length "length", the kind of offset amount to be read and the member
where the result is stored in are as follows.
IS-B IS-C
-------------------------------+---------------+---------------
Linear axis (metric input) 0.001 [mm] 0.0001 [mm]
Linear axis (inch input) 0.0001 [inch] 0.00001 [inch]
Rotation axis 0.001 [deg] 0.0001 [deg]
[Example]
The following program reads and displays the tool offset amounts for all
tools on a lathe (memory B/64 sets).
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>
#define MAXTOOL 64
[Name]
cnc_wrtofsr
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrtofsr( short length, struct iodbto *buf ) ;
struct iodbto {
short datano_s ; /* Start offset number. */
short type ; /* Offset type. */
short datano_e ; /* End offset number. */
union {
long m_ofs[N] ; /* M Series individual. */
long m_ofs_a[N] ; /* M Series Memory A all. */
long m_ofs_b[2*N] ; /* M Series Memory B all. */
long m_ofs_c[4*N] ; /* M Series Memory C all. */
short t_tip[N] ; /* T Series individual, */
/* direction of imaginary */
/* tool nose. */
long t_ofs[N] ; /* T Series individual. */
struct {
short tip ;
long data[4] ;
} t_ofs_a[N] ; /* T Series Memory A all. */
struct {
short tip ;
long data[8] ;
} t_ofs_b[N] ; /* T Series Memory B all. */
} u ;
} ;
/* N is number of the offset amounts to be read. */
[Arguments]
length Data block length.
buf Buffer in which the offset amounts are stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect offset number "buf.datano_s" or
"buf.datano_e". (This return code is returned in case
that any value except 1,..,(maximum number of offset)
was specified in offset number "s_number" or
"e_number".
EW_ATTRIB( 4) Incorrect offset type "buf.type".
EW_NOOPT( 6) There are no additional tool offset options required
for the specified offset number to be written. (See
"Read tool offset amount(cnc_rdtofs)" for details.)
EW_BUSY(-1) An attempt was made to execute this command when other
window processing of a low-speed type was in progress.
Execute the command after the window processing has
ended.
[Description]
Alters the tool offset amount stored in the CNC within the specified
range.
Specify the start offset number in "buf.datano_s" and the end one in
"buf.datano_e". Specify the kind of offset amount to be read in
"type". The combinations of the value specified in "type", the data
block length "length", the kind of offset amount to be read and the
member where the result is stored in are same as "Read tool offset
amount(range specified)(cnc_rdtofsr)". Refer description of it.
[Example]
The following program stores all tool offset amounts of
Machining-Series(Memory A/64 sets).
#include <data.h>
#include <fwindow.h>
#include <stdlib.h>
#include <string.h>
#define MAXTOOL 64
[Name]
cnc_rdzofs
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdzofs( short number, short axis, short length,
struct iodbaxis *buf ) ;
struct iodbaxis {
short datano ; /* Offset number. */
short type ; /* Axis number. */
long data[N] ; /* Offset data. */
} ; /* N is the amount of controlled
axes. */
Maximum controlled-axis number 32
[Arguments]
number Offset number ( 0, 1,..,6, 7,..,306 ).
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect of offset number "number". (Any data other
than 0,..,6 or 7,..,306 has been specified.)
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled
axes) has been specified.
EW_NOOPT( 6) There are no required options.
The related options;
- Work coordinate system ( G54 to G59 )
- Work coordinate system 48 sets ( G54.1P1-P48 )
- Work coordinate system 300 sets ( G54.1P1-P300 )
- Controlled axis expansion
EW_BUSY(-1) It was impossible to read a work origin offset because
a command from another application program to write the
work origin offset was already being executed.
[Description]
Reads the work origin offset amount stored in the CNC.
In the CNC, a work origin offset amount is provided for each controlled
axis (the first to 32nd controlled axes). The work origin offset amount
can be read either for individual axes separately or for all axes at a
time. If there is no controlled axis expansion option, however, it is
impossible to read a work origin offset amount for additional axes.
IS-B IS-C
-------------------------------+---------------+---------------
Linear axis (metric input) 0.001 [mm] 0.0001 [mm]
Linear axis (inch input) 0.0001 [inch] 0.00001 [inch]
Rotation axis 0.001 [deg] 0.0001 [deg]
[Example]
The following program displays the work origin offset amounts of the
specified number for all axes ( MAX (amount of axes = 32) ).
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
/* ofs is offset number to be displayed. */
void example( short ofs )
{
struct iodbaxis buf ;
unsigned int idx ;
cnc_rdzofs( ofs, -1, 4+4*MAX, &buf ) ;
for ( idx = 0 ; idx < MAX ; idx++ )
printf( "%u:%8ld\n", idx, buf.data[idx] ) ;
}
------------------------------------------------------------------------------
1.39 Write work origin offset. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_wrzofs
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrzofs( short length, struct iodbaxis *buf ) ;
struct iodbaxis {
short datano ; /* Offset number. */
short type ; /* Axis number. */
long data[N] ; /* Offset data. */
} ; /* N is the amount of controlled
axes. */
Maximum controlled-axis number 32
[Arguments]
length Data block length ( =4+4*(amount of axes to be read)).
buf Buffer in which the offset amount is stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect of offset number "number". (Any data other
than 0,..,6 or 7,..,306 has been specified.)
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled
axes) has been specified.
EW_NOOPT( 6) There are no required options.
(See "Read work origin offset(cnc_rdzofs)" for
details.)
EW_BUSY(-1) An attempt was made to execute this command when other
window processing of a low-speed type was in progress.
Execute the command after the window processing has
ended.
[Description]
Alters the work origin offset amount stored in the CNC.
In the CNC, a work origin offset amount is provided for each controlled
axis (the first to 32nd controlled axes). The work origin offset amount
can be rewritten either for individual axes separately or for all axes
at a time. If there is no controlled axis expansion option, however,
it is impossible to rewrite the work origin offset amount for additional
axes.
Store the work origin offset amount in "buf.data" with signed binary
format. (The negative value is represented as 2's complement.) Store
the work origin offset amount of specified axis in "buf.data[0]" in
case of altering one axis's data.
IS-B IS-C
-------------------------------+---------------+---------------
Linear axis (metric input) 0.001 [mm] 0.0001 [mm]
Linear axis (inch input) 0.0001 [inch] 0.00001 [inch]
Rotation axis 0.001 [deg] 0.0001 [deg]
[Example]
The following program alters the work origin offset amount of the
specified offset number and axis number.
#include <data.h>
#include <fwindow.h>
[Name]
cnc_rdzofsr
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdzofsr( short s_number, short axis, short e_number,
short length, struct iodbzo *buf ) ;
struct iodbzo {
short datano_s ; /* Start offset number. */
short type ; /* Axis number. */
short datano_e ; /* End offset number. */
long data[32*M] ; /* Offset data. */
} ; /* M is number of work origin */
/* offset amounts to be read. */
[Arguments]
s_number Start offset number ( 0, 1,..,6, 7,..,306 ).
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect of offset number "s_number" or "e_number".
(Any data other than 0,..,6 or 7,..,306 has been
specified.)
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled
axes) has been specified.
EW_NOOPT( 6) There are no required options.
(See "Read work origin offset(cnc_rdzofs)" for
details.)
EW_BUSY(-1) It was impossible to read a work origin offset amount
because a command from another application program to
write the work origin offset amount was already being
executed.
[Description]
Reads the work origin offset amount stored in the CNC within the
specified range.
In the CNC, a work origin offset amount is provided for each controlled
axis (the first to 32nd controlled axes). The work origin offset amount
can be read either for individual axes separately or for all axes at a
time. If there is no controlled axis expansion option, however, it is
impossible to read a work origin offset amount for additional axes.
IS-B IS-C
-------------------------------+---------------+---------------
Linear axis (metric input) 0.001 [mm] 0.0001 [mm]
Linear axis (inch input) 0.0001 [inch] 0.00001 [inch]
Rotation axis 0.001 [deg] 0.0001 [deg]
[Example]
The following program reads and displays the work origin offset amounts
of G54 to G59 for all the axes (up to 32 axes).
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>
[Name]
cnc_wrzofsr
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrzofsr( short length, struct iodbzo *buf ) ;
struct iodbzo {
short datano_s ; /* Start offset number. */
short type ; /* Axis number. */
short datano_e ; /* End offset number. */
long data[32*M] ; /* Offset data. */
} ; /* M is number of work origin */
/* offset amounts to be written. */
[Arguments]
length Data block length ( =6+4*(amount of axes to be read)*
(number of offset to be written) ).
buf Buffer in which the offset amounts are stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect of offset number "datano_s" or "datano_e".
(Any data other than 0,..,6 or 7,..,306 has been
specified.)
EW_ATTRIB( 4) Incorrect axis number "type".
Any data other than -1 or (1,..,amount of controlled
axes) has been specified.
EW_NOOPT( 6) There are no required options.
(See "Read work origin offset(cnc_rdzofs)" for
details.)
EW_BUSY(-1) An attempt was made to execute this command when other
window processing of a low-speed type was in progress.
Execute the command after the window processing has
ended.
[Description]
Alters the work origin offset amount stored in the CNC within the
specified range.
The work origin offset amounts are provided for all controlled axes
(the 1st axis,..,the 32nd axis) of the CNC. It is possible to alter
one offset amount for each axis or the whole for all axes at the same
time. However, in case of no controlled axes expansion option, the
work origin offset amounts for the additional axes can't be altered.
#include <data.h>
#include <fwindow.h>
#include <string.h>
[Name]
cnc_rdparam
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdparam( short number, short axis, short length,
struct iodbpsd *buf ) ;
struct iodbpsd {
short datano; /* parameter number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte parameter */
short idata; /* word parameter */
long ldata; /* 2-word parameter */
REALPRM rdata; /* real parameter */
char cdatas[MAX_AXIS];
/*bit/byte parameter with axis*/
short idatas[MAX_AXIS];
/* word parameter with axis */
long ldatas[MAX_AXIS];
/* 2-word parameter with axis */
REALPRM rdatas[MAX_AXIS];
/* real parameter with axis */
} u;
} ;
MAX_AXIS 32
[Arguments]
number Parameter number.
axis Axis number ( =(1,..,amount of controlled axes), or
-1, 0 ).
length Data block length ( =4+(byte size of the parameter)*
(MAX_AXIS) )
buf Buffer in which the parameter is stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect parameter number "number".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1, 0 or (1,..,amount of
controlled axes) has been specified.
[Description]
Reads the parameter data stored in the CNC.
The attribute of CNC parameter depends on the type and axis, and it is
different for each parameter.
The parameter data of none axis type parameter or the axis type
parameter data which was read for one specified axis is stored in
"buf.u.cdata/idata/ldata/rdata". The axis type parameters which were
read for all axes are stored in "buf.u.cdatas/idatas/ldatas/rdatas".
The data format depends on each parameter. The format of Byte/Word/
2-Word parameter is generally signed binary.
[Example]
The following program reads axis names of all controlled axes and
displays them.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>
void example( void )
{
struct iodbpsd buf ;
short ret, idx ;
ret = cnc_rdparam( 1020, -1, 4+10, &buf ) ; /* standard 10axes */
for ( idx = 0 ; idx < axno ; idx++ ) {
printf( "#%d", idx+1 ) ;
if ( buf.u.cdatas[idx] == 0 )
printf( "\033[7m%c\033[27m\n", idx+'1' ) ;
else
printf( "%c\n", buf.u.cdatas[idx] ) ;
}
}
------------------------------------------------------------------------------
1.43 Write parameter. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_wrparam
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrparam( short length, struct iodbpsd *buf ) ;
struct iodbpsd {
short datano; /* parameter number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte parameter */
short idata; /* word parameter */
long ldata; /* 2-word parameter */
REALPRM rdata; /* real parameter */
char cdatas[MAX_AXIS];
/*bit/byte parameter with axis*/
short idatas[MAX_AXIS];
/* word parameter with axis */
long ldatas[MAX_AXIS];
/* 2-word parameter with axis */
REALPRM rdatas[MAX_AXIS];
/* real parameter with axis */
} u;
} ;
MAX_AXIS 32
[Arguments]
length Data block length ( =4+(byte size of the parameter)*
(MAX_AXIS) )
buf Buffer in which the parameter is stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect parameter number "datano".
EW_ATTRIB( 4) Incorrect axis number "type".
Any data other than -1, 0 or (1,..,amount of
controlled axes) has been specified.
EW_PROT( 7 ) Write operation is prohibited.
[Description]
Alters the parameter data stored in the CNC.
This function is used for changing the various settings of CNC by the
application program, etc.
PW000 alarm :"PLEASE TURN OFF POWER" may be issued when some specific
parameters are written.
Refer "PARAMETER MANUAL" of CNC for details of each parameters.
Store the parameter data of none axis type parameter or the axis type
parameter data which will be written for one specified axis in
"buf.u.cdata/idata/ldata/rdata". Store the axis type parameters which
will be written for all axes in "buf.u.cdatas/idatas/ldatas/rdatas".
#include <data.h>
#include <fwindow.h>
[Name]
cnc_rdparar
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdparar( short s_number, short axis, short e_number,
short length, struct iodbpsdr *buf ) ;
struct iodbpsdr {
short datano; /* parameter number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte parameter */
short idata; /* word parameter */
long ldata; /* 2-word parameter */
REALPRM rdata; /* real parameter */
char cdatas[MAX_AXIS];
/*bit/byte parameter with axis*/
short idatas[MAX_AXIS];
/* word parameter with axis */
long ldatas[MAX_AXIS];
/* 2-word parameter with axis */
REALPRM rdatas[MAX_AXIS];
/* real parameter with axis */
} u;
} ;
MAX_AXIS 32
[Arguments]
s_number Start parameter number.
axis Axis number ( =(1,..,amount of controlled axes), or
-1, 0 ).
e_number End parameter number.
length Data block length ( = Sum of [4+(byte size of the
parameter)*(MAX_AXIS)] )
buf Buffer in which the parameters are stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect parameter number "s_number" or "e_number".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1, 0 or (1,..,amount of
controlled axes) has been specified.
[Description]
Reads the parameter data stored in the CNC within the specified range.
The attribute of CNC parameter depends on the type and axis, and it is
different for each parameter.
Specify the start parameter number in "s_number" and the end one in
"e_number" with binary format.
The new parameter will may be added according to updating CNC
software, addition of the new functions, etc.
If the new parameters will be added within reading range, ERROR 2 (
Incorrect data block length) will be returned or the application
program will not work correctly.
To avoid these mistakes, specify the continuous numbers of existing
parameters as the reading range.
Specify one of following values corresponding with each parameter
as axis number in "axis".
Any values are allowed for "axis" to read none axis type parameters.
In case that any axis type parameter exists in the specified range,
error will be returned by specifying "axis=0".
+-----------------------+
"Type" includes both parameter type in the upper byte and axis type in
the lower byte.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>
/* start/end are start/end number to be read, axis is axis number. */
short example( short start, short end, short axis )
{
struct odbsys info ;
struct iodbpsdr *buf, *ptr ;
short ret, idx1, idx2, axno, inc ;
cnc_sysinfo( &info ) ;
axno = atoi( info.axes ) ;
buf = (struct iodbpsdr *)calloc( 1, 1000 ) ;
ret = cnc_rdparar( start, axis, end, 1000, buf ) ;
ptr = buf ;
if ( !ret ) {
for ( idx1 = start ; idx1 <= end ; idx1++ ) {
if ( ( idx1 != 0 ) && ( ptr->datano == 0 ) ) break ;
printf( "No.%05d ", ptr->datano ) ;
switch ( ptr->type >> 8 ) {
case 0: printf( "BIT " ) ; break ;
case 1: printf( "BYTE" ) ; break ;
case 2: printf( "WORD" ) ; break ;
case 3: printf( "2WRD" ) ; break ;
}
switch ( ptr->type & 0xff ) {
case 0xff :
for ( idx2 = 0 ; idx2 < axno ; idx2++ ) {
printf( " #%d:", idx2+1 ) ;
switch ( ptr->type >> 8 ) {
case 0:
printf( "0x%02X",
(unsigned char)(ptr->u.cdatas[idx2]) ) ;
inc = 1 ; break ;
case 1:
printf( "%d", ptr->u.cdatas[idx2] ) ;
inc = 1 ; break ;
case 2:
printf( "%d", ptr->u.idatas[idx2] ) ;
inc = 2 ; break ;
case 3:
printf( "%ld", ptr->u.ldatas[idx2] ) ;
inc = 4 ; break ;
}
}
putchar( '\n' ) ;
ptr = (struct iodbpsdr *)(((char *)ptr)+4+8*inc) ;
break ;
/* to be continued on the next page... */
default :
printf( " #%d:", ptr->type & 0xff ) ;
case 0 :
switch ( ptr->type >> 8 ) {
case 0:
printf( " 0x%02X\n",
(unsigned char)(ptr->u.cdata) ) ;
inc = 1+1 ; break ;
case 1:
printf( " %d\n", ptr->u.cdata ) ;
inc = 1+1 ; break ;
case 2:
printf( " %d\n", ptr->u.idata ) ;
inc = 2 ; break ;
case 3:
printf( " %ld\n", ptr->u.ldata ) ;
inc = 4 ; break ;
}
ptr = (struct iodbpsdr *)(((char *)ptr)+4+inc) ;
break ;
}
}
}
else
printf( "ERROR!(%d)\n", ret ) ;
free( buf ) ;
return ( ret ) ;
}
------------------------------------------------------------------------------
1.45 Write parameters (multiple output). <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_wrparas
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrparas( short length, struct iodbpsdr *buf ) ;
struct iodbpsdr {
short datano; /* parameter number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte parameter */
short idata; /* word parameter */
long ldata; /* 2-word parameter */
REALPRM rdata; /* real parameter */
char cdatas[MAX_AXIS];
/*bit/byte parameter with axis*/
short idatas[MAX_AXIS];
/* word parameter with axis */
long ldatas[MAX_AXIS];
/* 2-word parameter with axis */
REALPRM rdatas[MAX_AXIS];
/* real parameter with axis */
} u;
} ;
MAX_AXIS 32
[Arguments]
length Data block length ( = Sum of [4+(byte size of the
parameter)*(MAX_AXIS)] )
buf Buffer in which the parameters are stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect parameter number "buf.datano".
EW_ATTRIB( 4) Incorrect axis number "buf.type".
Any data other than -1, 0 or (1,..,amount of
controlled axes) has been specified.
EW_PROT( 7 ) Write operation is prohibited.
[Description]
Alters the multiple parameter data stored in the CNC.
+-----------------------+
| Parameter number 1 | <-- buf[0].datano
|-----------------------|
| Type 1 | <-- buf[0].type
|-----------------------|
| Data 1 | <-- buf[0].u.cdata/idata/ldata/rdata
| | cdatas/idatas/ldatas/rdatas
|-----------------------|
:
|-----------------------|
| Parameter number n | <-- buf[n].datano
|-----------------------|
| Type n | <-- buf[n].type
|-----------------------|
| Data n | <-- buf[n].u.cdata/idata/ldata/rdata
| | cdatas/idatas/ldatas/rdatas
+-----------------------+
Store the parameter number in "Parameter number i"(buf[i].datano) with
binary format.
Store the parameter type in the upper byte of "Data i"(buf[i].type)
and the axis type in the lower byte.
Each buf[i] is suffixed with dummy data so that the total data size
is a multiple of 4-bytes.
[Example]
The following program specifies that M code Nos. 6080 to 6089 be
subjected to a macro call.
#include <data.h>
#include <fwindow.h>
#include <stdlib.h>
[Name]
cnc_rdset
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdset( short number, short axis, short length,
struct iodbpsd *buf ) ;
struct iodbpsd {
short datano; /* setting data number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte setting data */
short idata; /* word setting data */
long ldata; /* 2-word setting data */
REALPRM rdata; /* real setting data */
char cdatas[MAX_AXIS];
/*bit/byte set. data with axis*/
short idatas[MAX_AXIS];
/* word set. data with axis */
long ldatas[MAX_AXIS];
/* 2-word set. data with axis */
REALPRM rdatas[MAX_AXIS];
/* real set. data with axis */
} u;
};
MAX_AXIS 32
[Arguments]
number Setting parameter number.
axis Axis number ( =(1,..,amount of controlled axes),
or -1, 0 ).
length Data block length ( =4+(byte size of the setting
parameter)*(MAX_AXIS) )
buf Buffer in which the setting parameter is stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect setting parameter number "number".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1, 0 or (1,..,amount of
controlled axes) has been specified.
[Description]
Reads the setting parameter stored in the CNC.
This function is used for getting the information of I/O device from
the setting parameter to input/output via Reader/Puncher interface of
CNC by the application program, etc.
The attribute of setting data depends on the type and axis, and it is
different for each setting data.
The setting parameter of none axis type setting parameter or the axis
type setting parameter which was read for one specified axis is stored
in "buf.u.cdata/idata/ldata/rdata". The axis type setting parameter
which were read for all axes are stored in "buf.u.cdatas/idatas/ldatas/
rdatas".
#include <data.h>
#include <fwindow.h>
[Name]
cnc_wrset
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrset( short length, struct iodbpsd *buf ) ;
struct iodbpsd {
short datano; /* setting data number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte setting data */
short idata; /* word setting data */
long ldata; /* 2-word setting data */
REALPRM rdata; /* real setting data */
char cdatas[MAX_AXIS];
/*bit/byte set. data with axis*/
short idatas[MAX_AXIS];
/* word set. data with axis */
long ldatas[MAX_AXIS];
/* 2-word set. data with axis */
REALPRM rdatas[MAX_AXIS];
/* real set. data with axis */
} u;
} ;
MAX_AXIS 32
[Arguments]
length Data block length ( =4+(byte size of the setting
parameter)*(MAX_AXIS) )
buf Buffer in which the setting parameter is stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect setting parameter number "datano".
EW_ATTRIB( 4) Incorrect axis number "type".
Any data other than -1, 0 or (1,..,amount of
controlled axes) has been specified.
[Description]
Alters the setting parameter stored in the CNC.
This function is used for changing the setting of I/O device by the
application program, etc.
The attribute of setting data depends on the type and axis, and it is
different for each setting data. It is as follows, and can be got by
cnc_rdsetinfo() function.
Store the setting parameter data of none axis type setting parameter
or the axis type setting parameter data which will be written for one
specified axis in "buf.u.cdata/idata/ldata/rdata". Store the axis type
setting parameters which will be written for all axes in
"buf.u.cdatas/idatas/ldatas/rdatas".
The data format depends on each setting parameter. The format of
Byte/Word/2-Word/Real setting parameter is generally signed binary.
[Example]
See [Example] in "Read setting parameter (cnc_rdset)."
------------------------------------------------------------------------------
1.48 Read setting parameters (range specified). <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_rdsetr
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdsetr( short s_number, short axis, short e_number,
short length, struct iodbpsdr *buf ) ;
struct iodbpsdr {
short datano; /* setting data number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte setting data */
short idata; /* word setting data */
long ldata; /* 2-word setting data */
REALPRM rdata; /* real setting data */
char cdatas[MAX_AXIS];
/*bit/byte set. data with axis*/
short idatas[MAX_AXIS];
/* word set. data with axis */
long ldatas[MAX_AXIS];
/* 2-word set. data with axis */
REALPRM rdatas[MAX_AXIS];
/* real set. data with axis */
} u;
} ;
MAX_AXIS 32
[Arguments]
s_number Start setting parameter number.
axis Axis number ( =(1,..,amount of controlled axes), or
-1, 0 ).
e_number End setting parameter number.
length Data block length ( = Sum of [4+(byte size of the
setting parameter)*(MAX_AXIS)] )
buf Buffer in which the setting parameters are stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect setting parameter number "s_number" or
"e_number".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1, 0 or (1,..,amount of
controlled axes) has been specified.
[Description]
Reads the setting parameter data stored in the CNC within the
specified range.
The attribute of setting data depends on the type and axis, and it is
different for each setting data.
Setting data type Meaning Byte size
---------------------------+---------------------------------+---------
Bit setting data Every bits have each definition. 1
Bit setting data with axis Every bits have each definition. 1
(each axis)
Byte setting data 1-byte data is stored. 1
Byte setting data with axis 1-byte data is stored.(each axis) 1
Word setting data 2-byte data is stored. 2
Word setting data with axis 2-byte data is stored.(each axis) 2
2-Word setting data 4-byte data is stored. 4
2-Word setting data with ax.4-byte data is stored.(each axis) 4
Real setting data 4-byte data which indicates value
of variable and 4-byte data which
indicates number of places of 8
decimals are stored.
Real setting data with ax. 4-byte data whidh indicates value
of variable and 4-byte data which
indicates number of places of 8
decimals are stored.(each axis)
Any values are allowed for "axis" to read none axis type setting
parameters. In case that any axis type setting parameter exists in the
specified range, error will be returned by specifying "axis=0".
"Type" includes both parameter type in the upper byte and axis type in
the lower byte.
[Example]
This function can be used in the same manner as described in "Read
parameters (range specified) (cnc_rdparar)." See [Example] in this
section.
------------------------------------------------------------------------------
1.49 Write setting parameters (multiple output). <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_wrsets
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrsets( short length, struct iodbpsdr *buf ) ;
struct iodbpsdr {
short datano; /* setting data number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte setting data */
short idata; /* word setting data */
long ldata; /* 2-word setting data */
REALPRM rdata; /* real setting data */
char cdatas[MAX_AXIS];
/*bit/byte set. data with axis*/
short idatas[MAX_AXIS];
/* word set. data with axis */
long ldatas[MAX_AXIS];
/* 2-word set. data with axis */
REALPRM rdatas[MAX_AXIS];
/* real set. data with axis */
} u;
} ;
MAX_AXIS 32
[Arguments]
length Data block length ( = Sum of [4+(byte size of the
setting parameter)*(MAX_AXIS)] )
buf Buffer in which the setting parameters are stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect setting parameter number "buf.datano".
EW_ATTRIB( 4) Incorrect axis number "buf.type".
Any data other than -1, 0 or (1,..,amount of
controlled axes) has been specified.
[Description]
Alters the multiple setting parameter data stored in the CNC.
The attribute of setting data depends on the type and axis, and it is
different for each setting data. It is as follows, and can be got by
cnc_rdsetinfo() function.
+-----------------------+
|Setting param. Number 1| <-- buf[0].datano
|-----------------------|
| Type 1 | <-- buf[0].type
|-----------------------|
| Data 1 | <-- buf[0].u.cdata/idata/ldata/rdata
| | cdatas/idatas/ldatas/rdatas
|-----------------------|
:
|-----------------------|
|Setting param. Number n| <-- buf[n].datano
|-----------------------|
| Type n | <-- buf[n].type
|-----------------------|
| Data n | <-- buf[n].u.cdata/idata/ldata/rdata
| | cdatas/idatas/ldatas/rdatas
+-----------------------+
Store the setting parameter number in "Setting param. Number i"
(buf[i].datano) with binary format.
Store the setting parameter type in the upper byte of "Data i"
(buf[i].type) and the axis type in the lower byte.
Each buf[i] is suffixed with dummy data so that the total data size
is a multiple of 4-bytes.
[Example]
This function can be used in the same manner as described in "Write
parameters (multiple output) (cnc_wrparas)." See [Example] in this
section.
------------------------------------------------------------------------------
1.50 Read pitch error compensation data (range specified). <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_rdpitchr
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdpitchr( short s_number, short e_number, short length,
struct iodbpi *buf ) ;
struct iodbpi {
short datano_s ; /* Start pitch error compensation */
/* data number. */
short dummy ; /* Not used. */
short datano_e ; /* End pitch error compensation */
/* data number. */
char data[N] ; /* Pitch error compensation data. */
} ; /* N is the amount of compensation */
/* data to be read. */
[Arguments]
s_number Start pitch error compensation number.
e_number End pitch error compensation number.
length Data block length ( =6+(number of compensation data to
be read) )
buf Buffer in which the pitch error compensation data are
stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect pitch error compensation number "s_number"
or "e_number".
[Description]
Reads the pitch error compensation data stored in the CNC within the
specified range.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>
/* start/end are start/end number to be read. */
short example( short start, short end )
{
struct iodbpi *buf ;
short ret, idx ;
buf = (struct iodbpi *)malloc( 1024 ) ;
ret = cnc_rdpitchr( start, end, 6+(end-start+1), buf ) ;
if ( !ret )
for ( idx = 0 ; idx < end-start+1 ; idx++ )
printf( "#%04d %+d\n", idx+start, buf->data[idx] ) ;
free( buf ) ;
return ( ret ) ;
}
------------------------------------------------------------------------------
1.51 Write pitch error compensation data (range specified). <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_wrpitchr
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrpitchr( short length, struct iodbpi *buf ) ;
struct iodbpi {
short datano_s ; /* Start pitch error compensation */
/* number. */
short dummy ; /* Not used. */
short datano_e ; /* End pitch error compensation */
/* number. */
char data[N] ; /* Pitch error compensation data. */
} ; /* N is number of compensation data */
/* to be written. */
[Arguments]
length Data block length ( =6+(number of compensation data to
be written) )
buf Buffer in which the pitch error compensation data are
stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect pitch error compensation number
"buf.datano_s" or "buf.datano_e".
EW_BUSY(-1) An attempt was made to execute this command when other
window processing of a low-speed type was in progress.
[Description]
Alters the pitch error compensation data stored in the CNC within the
specified range.
Store the pitch error compensation data "buf.data" with signed binary
format. (The negative value is represented as 2's complement.)
[Example]
The following program alters the pitch error compensation data within
the specified number range.
#include <data.h>
#include <fwindow.h>
#include <stdlib.h>
[Name]
cnc_rdmacro
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdmacro( short number, short length, struct odbm *buf ) ;
struct odbm {
short dummy ; /* Not used. */
short datano ; /* Custom macro variable number. */
long mcr_val ; /* Custom macro variable value. */
short dec_val ; /* Digit number after decimal point.*/
} ;
[Arguments]
number Custom macro variable number.
length Data block length ( =10 ).
buf Buffer in which the custom macro variable data is
stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect custom macro variable number "number".
EW_DATA( 5) Value of the custom macro variable is out of the limit.
EW_NOOPT( 6) There are no required options.
The related options;
- Custom macro.
- Custom macro common variable addition (#100 to #199
and #500 to #999)
EW_BUSY(-1) It was impossible to read a custom macro variable
because a command from another application program to
write the custom macro variable was already being
executed. Alternatively, an attempt was made to execute
this command when other window processing of a low-speed
type was in progress. Execute the command after the
window processing has ended.
[Description]
Reads the custom macro variable data stored in the CNC.
Variable data
displayed in
CNC screen mcr_val dec_val
---------------+---------------+---------------
Blank(void) 0 -1
0.000 0 3
0.0000001 1 7
0000.0001 1 4
00000.100 100 3
00001.000 1000 3
00010.000 10000 3
100000.00 10000000 2
99999999. 99999999 0
00123.000 123000 3
-00123.000 -123000 3
[Example]
The following program reads the custom macro variable data of
specified number and displays it.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <string.h>
/* number is variable number to be read. */
short example( short number )
{
struct odbm buf ;
char strbuf[11] ;
short ret ;
ret = cnc_rdmacro( number, 10, &buf ) ;
if ( !ret ) {
sprintf( &strbuf[1], "%09ld", buf.mcr_val ) ;
if ( strbuf[1] == '0' ) strbuf[1] = ' ' ;
strncpy( &strbuf[0], &strbuf[1], 9 - buf.dec_val ) ;
strbuf[9-buf.dec_val] = '.' ;
printf( "%s\n", strbuf ) ;
}
else
printf( "**********\n" ) ;
return ( ret ) ;
}
------------------------------------------------------------------------------
1.53 Write custom macro variable. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_wrmacro
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrmacro( short number, short length, long mcr_val
, short dec_val ) ;
[Arguments]
number Custom macro variable number.
length Data block length ( =10 ).
mcr_val Custom macro variable value.
dec_val Digit number after decimal point.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect custom macro variable number "number".
EW_DATA( 5) Value of the custom macro variable is out of the limit.
EW_NOOPT( 6) There are no required options.
The related options;
- Custom macro.
- Custom macro common variable addition (#100 to #199
and #500 to #999)
EW_BUSY(-1) An attempt was made to execute this command when other
window processing of a low-speed type was in progress.
Execute the command after the window processing has
ended.
[Description]
Writes the custom macro variable data in the CNC.
The following values are stored concretely. (These are same as format
of cnc_rdmacro() function.)
Value to be
written mcr_val dec_val
---------------+---------------+--------
void 0 -1
0.000 0 3
0.0000001 1 7
0000.0001 1 4
00000.100 100 3
00001.000 1000 3
00010.000 10000 3
100000.00 10000000 2
99999999. 99999999 0
00123.000 123000 3
-00123.000 -123000 3
[Example]
The following program writes the specified value in the specified
custom macro variable.
#include <data.h>
#include <fwindow.h>
[Name]
cnc_rdmacror
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdmacror( short s_number, short e_number, short length,
struct iodbmr *buf ) ;
struct iodbmr {
short datano_s ; /* Start custom macro variable number.*/
short dummy ; /* Not used. */
short datano_e ; /* End custom macro variable number.*/
struct {
long mcr_val ; /* Custom macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} data[N] ; /* N is number of variables to be read. */
} ;
[Arguments]
s_number Start custom macro variable number.
e_number End custom macro variable number.
length Data block length ( =6+6*(number of variables to be
read) )
buf Buffer in which the custom macro variable data are
stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect custom macro variable number "datano_s"
or "datano_e".
EW_DATA( 5) Value of the custom macro variable is out of the limit.
EW_NOOPT( 6) There are no required options.
The related options;
- Custom macro.
- Custom macro common variable addition (#100 to #199
and #500 to #999)
EW_BUSY(-1) It was impossible to read a custom macro variable
because a command from another application program to
write the custom macro variable was already being
executed. Alternatively, an attempt was made to execute
this command when other window processing of a low-speed
type was in progress. Execute the command after the
window processing has ended.
[Description]
Reads the custom macro variable data stored in the CNC within the
specified range.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
[Name]
cnc_wrmacror
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrmacror( short length, struct iodbmr *buf ) ;
struct iodbmr {
short datano_s ; /* Start custom macro variable number. */
short dummy ; /* Not used. */
short datano_e ; /* End custom macro variable number. */
struct {
long mcr_val ; /* Custom macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} data[N] ; /* N is number of variables to be written. */
} ;
[Arguments]
length Data block length ( =6+6*(number of variables to be
written) )
buf Buffer in which the custom macro variable data are
stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect custom macro variable number "datano_s"
or "datano_e".
EW_DATA( 5) Value of the custom macro variable is out of the limit.
EW_NOOPT( 6) There are no required options.
The related options;
- Custom macro.
- Custom macro common variable addition (#100 to #199
and #500 to #999)
EW_BUSY(-1) An attempt was made to execute this command when other
window processing of a low-speed type was in progress.
Execute the command after the window processing has
ended.
[Description]
Writes the custom macro variable data stored in the CNC within the
specified range.
[Example]
The following program writes the integer values into the custom macro
variables within the specified range.
#include <data.h>
#include <fwindow.h>
#include <stdlib.h>
[Name]
cnc_rdpmacro
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdpmacro( long number, struct odbpm *buf ) ;
struct odbpm {
long datano ; /* P-code macro variable number. */
short dummy ; /* Not used. */
union {
struct {
long mcr_val ; /* P-code macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} p6 ;
struct {
short mcr_val ; /* P-code macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} p2 ;
} u ;
} ;
[Arguments]
number P-code macro variable number. ( >= 10000 )
buf Buffer in which the P-code macro variable data is
stored.
[Return]
EW_OK( 0) Successful.
EW_NUMBER( 3) Incorrect P-code macro variable number "number".
EW_DATA( 5) Value of the P-code macro variable is out of the limit.
EW_NOOPT( 6) Macro executor option isn't added, or macro module
isn't loaded.
EW_BUSY(-1) An attempt was made to execute this command when other
window processing of a low-speed type was in progress.
Execute the command after the window processing has
ended.
[Description]
Reads the macro executor variable (P-code macro variable) data of
specified number.
[Example]
The following program reads and displays a P code macro variable having
a specified number.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <string.h>
[Name]
cnc_wrpmacro
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrpmacro( long number, long mcr_val, short dec_val ) ;
[Arguments]
number P-code macro variable number. ( >= 10000 )
mcr_val P-code macro variable value.
dec_val Digit number after decimal point.
[Return]
EW_OK( 0) Successful.
EW_NUMBER( 3) Incorrect P-code macro variable number "number".
EW_NOOPT( 6) Macro executor option isn't added, or macro module
isn't loaded.
EW_BUSY(-1) An attempt was made to execute this command when other
window processing of a low-speed type was in progress.
Execute the command after the window processing has
ended.
[Description]
Writes the macro executor variable (P-code macro variable) data of
specified number.
Value to be
written mcr_val dec_val
---------------+---------------+--------
void 0 -1
0.000 0 3
0.0000001 1 7
0000.0001 1 4
00000.100 100 3
00001.000 1000 3
00010.000 10000 3
100000.00 10000000 2
99999999. 99999999 0
00123.000 123000 3
-00123.000 -123000 3
This function can write only P-code macro variables whose number are
equal to or more than 10000.
[Example]
The following program writes the specified value in the specified
P-code macro variable.
#include <data.h>
#include <fwindow.h>
[Name]
cnc_rdpmacror
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdpmacror( long s_number, long e_number, short length,
struct iodbpr *buf ) ;
struct iodbpr {
long datano_s ; /* Start P-code macro variable number. */
short dummy ; /* Not used. */
long datano_e ; /* End P-code macro variable number. */
union {
struct {
long mcr_val ; /* P-code macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} p6_r ;
struct {
short mcr_val ; /* P-code macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} p2_r ;
} pm_r[N] ; /* N is number of variables to be read. */
} ;
[Arguments]
s_number Start P-code macro variable number.
e_number End P-code macro variable number.
length Data block length ( =10+6*(number of variables to be
read) )
buf Buffer in which the P-code macro variable data are
stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect P-code macro variable number "s_number"
or "e_number".
EW_DATA( 5) Value of the P-code macro variable is out of the limit.
EW_NOOPT( 6) Macro executor option isn't added, or macro module
isn't loaded.
EW_BUSY(-1) It was impossible to read a P code macro variable
because the CNC was updating the P code macro variable.
[Description]
Reads the macro executor variable (P-code macro variable) data within
the specified range.
Also expanded P-code macro variables (after #20000) which are used
as fixed integer are read as floating point variables.
This function can read only P-code macro variables whose number are
equal to or more than 10000.
[Example]
The following program reads and displays P code macro variables in a
specified range.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
[Name]
cnc_wrpmacror
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrpmacror( short length, struct iodbpr *buf ) ;
struct iodbpr {
long datano_s ; /* Start P-code macro variable number. */
short dummy ; /* Not used. */
long datano_e ; /* End P-code macro variable number. */
union {
struct {
long mcr_val ; /* P-code macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} p6_r ;
struct {
short mcr_val ; /* P-code macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} p2_r ;
} pm_r[N] ; /* N is number of variables to be read. */
} ;
[Arguments]
length Data block length ( =10+6*(number of variables to be
written) )
datano_s Start P-code macro variable number. ( >= 10000 )
datano_e End P-code macro variable number.
mcr_val P-code macro variable value.
dec_val Digit number after decimal point.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect P-code macro variable number "s_number"
or "e_number".
EW_NOOPT( 6) Macro executor option isn't added, or macro module
isn't loaded.
EW_BUSY(-1) An attempt was made to execute this command when other
window processing of a low-speed type was in progress.
Execute the command after the window processing has
ended.
[Description]
Writes the macro executor variable (P-code macro variable) data within
the specified range.
Also expanded P-code macro variables (after #20000) which are used
as fixed integer are written as floating point variables.
The window internal routine converts floating format into fixed
integer format.
This function can write only P-code macro variables whose number are
equal to or more than 10000.
[Example]
The following program writes the integer values into the P-code macro
variables within the specified range.
#include <data.h>
#include <fwindow.h>
#include <stdlib.h>
[Name]
cnc_modal
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_modal( short type, short block, struct odbmdl *buf ) ;
struct odbmdl {
short datano; /* Kind of modal data. */
short type; /* Objective block. */
union {
char g_data; /* Modal data of G code. */
char g_rdata[35]; /* Modal data of G code. */
char g_1shot[4];/* 1 shot Modal data of G code.*/
struct {
long aux_data;
/* Modal data other than G code.*/
char flag1; /* Flag1. */
char flag2; * Flag2. */
}aux;
struct {
long aux_data;
/* Modal data other than G code.*/
char flag1; /* Flag1. */
char flag2; /* Flag2. */
}raux1[27];
struct {
long aux_data;
/* Modal data other than G code.*/
char flag1; /* Flag1. */
char flag2; /* Flag2. */
}raux2[MAX_AXIS]; /* MAX_AXIS : Maximum */
}modal; /* controlled-axis number */
};
[Arguments]
type Specifies the type of modal data. (Details are described later.)
[Description]
Reads the modal information of CNC.
The readable modal data are modal G code, M/S/T code or commanded data
such as F.
The type of a union for storing modal data varies depending on the type
of the modal data. When accessing read results, use a union that
matches the data type.
(1) Reading modal G code.
7 6 5 4 3 2 1 0
┌─┬─┬─┬─┬─┬─┬─┬─┐
┌┼・│ Code in each group │ 1 byte
│└─┴─┴─┴─┴─┴─┴─┴─┘
└─┬──→ 0 : The G code is not specified in the current
│ block.
└──→ 1 : The G code is specified in the current block.
type Address
-------+------------------------
100 B (2nd auxiliary function)
101 D
102 - (Reserved)
103 F
104 H [M]
105 L
106 M
107 S
108 T
109 R [M]
110 P [M]
111 Q [M]
112 A
113 C
114 I
115 J
116 K
117 N
118 O
119 U
120 V
121 W
122 X
123 Y
124 Z
125 M (2nd M code)
126 M (3rd M code)
-------+------------------------
200 1st axts
201 2nd axts
202 3rd axts
203 4th axts
204 5th axts
205 6th axts
206 7th axts
207 8th axts
-------+------------------------
Data of a type indicated [M] is read as modal data for the
machining center series and command data for the lathe series.
To read data of types 100 to 199 at a time, specify -2.
The data is set in the buf.modal.raux1 array.
To read data of types 200 to 299 at a type, specify -3.
The data is set in the buf.modal.raux2 array.
┌───────────────┐
│ Data │ : 4 bytes
├───────────────┤
┌─│ FLAG1 │ : 1 byte
│ ├───────────────┤
┌┼─│ FLAG2 │ : 1 byte
││ └───────────────┘
││ 7 6 5 4 3 2 1 0
││ ┌─┬─┬─┬─┬─┬─┬─┬─┐
│└→│ │ │ │-│Number of │
│ │ │ │ │ │input digits │
│ └─┴─┴─┴─┴─┴─┴─┴─┘
│ │ │ ├─→ 0 : The data is positive.
│ │ │ └─→ 1 : The data is negative.
│ │ ├───→ 0 : No decimal point is specified for the data.
│ │ └───→ 1 : A decimal point is specified for the data.
│ ├─────→ 0 : The data is not specified as the current
│ │ block.
│ └─────→ 1 : The data is specified as the current block.
│ ┌─┬─┬─┬─┬─┬─┬─┬─┐
└─→│Number of digits after │
│the decimal point │
└─┴─┴─┴─┴─┴─┴─┴─┘
* Even if no decimal point is specified, the number of digits after
the decimal point may not be 0.
* For the command addresses M, S, T, and B, a parameter-specified
allowable number of digits is returned as the number of input digits.
The numbers in the g_1shot column of the above table are stored to bits
7 6 5 4 3 2 1 0
┌─┬─┬─┬─┬─┬─┬─┬─┐
┌┼* │ Code in each group │ 1 byte
│└─┴─┴─┴─┴─┴─┴─┴─┘
└─┬──→ 0: The G code is not specified in the current
│ block.
└──→ 1: The G code is specified in the current block.
To read data of all types related to one-shot G codes, specify -4.
The data of type 300 is set in the buf.modal.g_1shot[0].
------------------------------------------------------------------------------
1.61 Read diagnostics data. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_diagnoss
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_diagnoss( short number, short axis, short length,
struct iodbpsd *buf ) ;
struct iodbpsd {
short datano; /* diagnosis number */
short type; /* axis number */
union {
char cdata; /* bit/byte diagnosis */
short idata; /* word diagnosis */
long ldata; /* 2-word diagnosis */
char cdatas[N];
/*bit/byte diagnosis with axis*/
short idatas[N];
/* word diagnosis with axis */
long ldatas[N];
/* 2-word diagnosis with axis */
} u ;
} ;
/* N : max. controlled axes */
[Arguments]
number Diagnostic number.
axis Axis number ( =(1,..,amount of controlled axes), or
-1, 0 ).
length Data block length
( =4+(byte size of the diagnostics data)*(amount of
axes to be read) )
buf Buffer in which the diagnostics data are stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect diagnostic number "number".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1, 0 or (1,..,amount of
controlled axes) has been specified.
EW_NOOPT( 6) An option (such as a remote buffer) required to use data
The data that is displayed in bit form on the CNC diagnostic screen is
of byte type.
Axis type data can be read either for individual axes separately or for
all axes at a time.
Refer "MAINTENANCE MANUAL" of CNC for details of each diagnostics
data.
The diagnostics data of none axis type data or the axis type data
which was read for one specified axis is stored in
"buf.u.cdata/idata/ldata". The axis type data which were read
for all axes are stored in "buf.u.cdatas/idatas/ldatas".
This function reads the "raw" diagnostics data. In case of reading bit
data, also the masked bit on the CNC's diagnostics screen can be read
without masking. Therefore, there may be difference between the
contents of displayed data on the CNC's screen and ones read by this
function.
Reference
~~~~
Types of diagnostics data displayed on the CNC screen
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_diagnosr
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_diagnosr( short s_number, short axis, short e_number,
short length, struct iodbpsdr *buf ) ;
struct iodbpsdr {
short datano; /* diagnosis number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte diagnosis */
short idata; /* word diagnosis */
long ldata; /* 2-word diagnosis */
char cdatas[32];
/*bit/byte diagnosis with axis*/
short idatas[32];
/* word diagnosis with axis */
long ldatas[32;
/* 2-word diagnosis with axis */
} u ;
} ;
[Arguments]
s_number Start diagnostic number.
axis Axis number ( =(1,..,amount of controlled axes), or
-1, 0 ).
e_number End diagnostic number.
length Data block length
( = Sum of [4+(byte size of the diagnostics data)*(
amount of axes to be read)] )
buf Buffer in which the diagnostics data are stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect diagnostic number "s_number" or "e_number".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1, 0 or (1,..,amount of
controlled axes) has been specified.
EW_NOOPT( 6) An option (such as a remote buffer) required to use data
having a specified diagnose data number has not been
added.
EW_BUSY(-1) An attempt was made to execute this command when other
window processing of a low-speed type was in progress.
Execute the command after the window processing has
ended.
[Description]
Reads the contents of data displayed in the diagnostics screen of CNC
within the specified range.
The data that is displayed in bit form on the CNC diagnostic screen is
of byte type.
Axis type data can be read either for individual axes separately or for
all axes at a time.
Specify the start diagnostic number in "s_number" and the end one in
"e_number" with binary format. The new diagnostics data will may be
added according to updating CNC software, addition of the new
functions, etc. If the new diagnostics data will be added within
reading range, ERROR 2 (Incorrect data block length) will be returned
or the application program will not work correctly. To avoid these
mistakes, specify the continuous numbers of existing diagnostics data
as the reading range.
Specify one of following values corresponding with each diagnostic
data as axis number in "axis".
Any values are allowed for "axis" to read none axis type diagnostics
data. In case that any axis type diagnostics data exists in the
specified range, error will be returned by specifying "axis=0".
The read diagnostics data are stored in "buf" in following order.
+-----------------------+
| Data number 1 | <-- buf[0].datano
|-----------------------|
| Type 1 | <-- buf[0].type
|-----------------------|
| Data 1 | <-- buf[0].u.cdata/idata/ldata/
| | cdatas/idatas/ldatas
|-----------------------|
:
|-----------------------|
| Data number n | <-- buf[n].datano
|-----------------------|
| Type n | <-- buf[n].type
|-----------------------|
| Data n | <-- buf[n].u.cdata/idata/ldata/
| | cdatas/idatas/ldatas
+-----------------------+
"Type" includes both diagnostics data type in the upper byte and axis
type in the lower byte.
Type (upper byte) Diagnostics data type
-----------------------+---------------------
0 Byte
1 Word
2 2-Word
In case of reading bit data, also the masked bit on the CNC's
diagnostics screen can be read without masking. Therefore, there may be
difference between the contents of displayed data on the CNC's screen
and ones read by this function.
[Example]
The following program reads diagnose data in a specified range for a
specified axis and displays it on the screen.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>
/* start/end are start/end number to be read. */
/* axis is axis number. */
short example( short start, short end, short axis )
{
struct odbsys info ;
struct iodbpsdr *buf, *ptr ;
short ret, idx1, idx2, axno, inc ;
cnc_sysinfo( &info ) ;
axno = atoi( info.axes ) ;
buf = (struct iodbpsdr *)calloc( 1, 1000 ) ;
ret = cnc_diagnosr( start, axis, end, 1000, buf ) ;
ptr = buf ;
if ( !ret ) {
for ( idx1 = start ; idx1 <= end ; idx1++ ) {
if ( ( idx1 != 0 ) && ( ptr->datano == 0 ) ) break ;
printf( "No.%05d ", ptr->datano ) ;
switch ( ptr->type >> 8 ) {
case 0: printf( "BYTE" ) ; break ;
case 1: printf( "WORD" ) ; break ;
case 2: printf( "2WRD" ) ; break ;
}
switch ( ptr->type & 0xff ) {
case 0xff :
for ( idx2 = 0 ; idx2 < axno ; idx2++ ) {
printf( " #%d:", idx2+1 ) ;
switch ( ptr->type >> 8 ) {
case 0:
printf( "%02X", ptr->u.cdatas[idx2] ) ;
inc = 1 ; break ;
case 1:
printf( "%d", ptr->u.idatas[idx2] ) ;
inc = 2 ; break ;
case 2:
printf( "%ld", ptr->u.ldatas[idx2] ) ;
inc = 4 ; break ;
}
}
putchar( '\n' ) ;
ptr = (struct iodbpsdr *)(((char *)ptr)+4+8*inc) ;
break ;
/* to be continued on the next page... */
default :
printf( " #%d:", ptr->type & 0xff ) ;
case 0:
switch ( ptr->type >> 8 ) {
case 0:
printf( " %02X\n", ptr->u.cdata ) ;
inc = 2 ; break ;
case 1:
printf( " %d\n", ptr->u.idata ) ;
inc = 2 ; break ;
case 2:
printf( " %ld\n", ptr->u.ldata ) ;
inc = 4 ; break ;
}
ptr = (struct iodbpsdr *)(((char *)ptr)+4+inc) ;
break ;
}
}
}
else
printf( "ERROR!(%d)\n", ret ) ;
free( buf ) ;
return ( ret ) ;
}
------------------------------------------------------------------------------
1.63 Read A/D conversion data. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_adcnv
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_adcnv( short inp_type, short av_type, struct odbad *buf ) ;
struct odbad {
short datano ; /* Kind of analog voltage. */
short type ; /* Input channel or controlled axis number. */
short data ; /* Voltage data. */
} ;
[Arguments]
inp_type Kind of analog voltage ( =0, 2 ).
av_type Controlled axis number of CNC.
( 1,..,(amount of controlled axes) )
buf Buffer in which the A/D conversion data is stored.
[Return]
EW_OK( 0) Successful.
EW_ATTRIB( 4) Incorrect input channel or controlled axis number
"av_type".
[Description]
Reading the load information of the controlled axis of the CNC.
Reads the load current data of the controlled axis of the CNC which is
converted into analog voltage via A/D converter.
This axis number is the servo axis number, and may be different from
the controlled axis number of the CNC.
[Name]
cnc_rdopmsg
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdopmsg( short type , short length, struct msg *buf ) ;
struct msg {
short datano ; /* Operator's message number. */
short type ; /* Kind of operator's message. */
short char_num ; /* Message length. */
char data[N] ; /* Operator's message. */
} ; /* N is maximum length of string. */
[Arguments]
type Kind of the operator's message ( =0,1,2,3 ).
length Data block length ( =6+(maximum length of string) )
buf Buffer in which the operator's message is stored.
[Return]
EW_OK( 0) Successful.
EW_ATTRIB( 4) Incorrect kind of the operator's message "type".
EW_NOOPT( 6) External message or option of external data input isn't
added.
[Description]
Reads the contents of the operator's message displayed in the CNC's
screen.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_setpath
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_setpath( int path_no ) ;
[Arguments]
path_no Path number.
[Return]
EW_OK( 0) Successful.
EW_PATH(11) Incorrect path number "path_no".
[Description]
Selects the path number which is objective path of the CNC window
functions in the multi-path system.
The 1st path is selected during this function has never been called
since power-on.
[Example]
The following program sets up a specified path and processing target
path.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_getpath
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_getpath( short *path_no, short *maxpath_no ) ;
[Arguments]
path_no Current selected path number.
maxpath_no Maximum path number.
[Return]
EW_OK( 0) Successful.
[Description]
Reads the current selected path number which is the objective path of
the CNC window functions.
[Example]
The following program reads and displays information about the current
processing target path.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
void example( void )
{
short path, max ;
cnc_getpath( &path, &max ) ;
printf( "Current target path is PATH #%d (max:%d).\n", path, max ) ;
}
------------------------------------------------------------------------------
1.67 Set calendar timer of CNC. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
cnc_settimer
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_settimer( struct iodbtimer *buf ) ;
struct iodbtimer {
short type ; /* Spec. of date or time. */
short dummy ; /* Not used. */
union {
struct {
short year ; /* Year. */
short month ; /* Month. */
short date ; /* Date. */
} date ;
struct {
short hour ; /* Hour. */
short minute ;/* Minute. */
short second ;/* Second. */
} time ;
} data ;
} ;
[Arguments]
buf Buffer in which the date or time data are stored.
[Return]
EW_OK( 0) Successful.
EW_NUMBER( 3) Incorrect spec. of date or time "buf.type".
EW_DATA( 5) Incorrect date or time data.
EW_BUSY(-1) Failed to set the data to the calendar timer device.
Any hardware may be out of order.
[Description]
Sets the date or time data to the calendar timer device of the CNC
unit.
CNC software and C library read date and time from the calendar timer
device of the CNC unit. This function set the date and time data to
that calendar timer device.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_rdspload
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdspload( short sp_no, struct odbspn *buf ) ;
struct odbspn {
short datano ; /* Spindle number. */
short type ; /* Not used. */
short data[2] ; /* Spindle load data. */
} ;
[Arguments]
sp_no Spindle number.
buf Buffer in which the spindle load data are stored.
[Return]
EW_OK( 0) Successful.
EW_NUMBER( 3) Incorrect spindle number "sp_no".
EW_NOOPT( 6) The required option (Spindle serial output) is not
added.
[Description]
Reads the load information of the serial spindle controlled by the
CNC.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
cnc_rdexecprog
[Syntax]
#include <fwindow.h>
short cnc_rdexecprog( unsigned short *length, short *blknum
, char *data ) ;
[Arguments]
length Size of the buffer for storing executing program,
character number of read executing program.
blknum Number of buffered blocks.
data Buffer in which executing program text is stored
(ASCII string).
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect buffer size "length".
[Description]
Reads the contents of the NC program followig the currently executing
block.
This function is used for building the original screen like "Program
Check Screen" of CNC, etc.
Specify the byte-size of the buffer "data" for the storing executing
program in "length".
In case that M-code by which the prgram is rewinded to the top such as
M02 or M30 is programmed in the tail of the NC program, the following
string is returned while the block of M-code is being executed.
This is caused by the process of CNC. The CNC software rewinds the
program when the NC program is read by this function.
This function reads the contents of executing program only when the
operating mode of CNC is "MEM" or "MDI". When the other mode,
"length=0" and "blknum=0" are returned.
[Example]
The following program displays an NC program being currently executed
on the screen.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <conio.h>
#define BUFLEN 200
[Name]
cnc_rdmovrlap
[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdmovrlap( short axis, short length, struct iodbovl *buf ) ;
struct iodbovl {
short datano ; /* Not used. */
short type ; /* Axis number. */
long data[2][32] ; /* Override amount. */
} ;
[Arguments]
axis Axis number ( =-1:for only all axes).
length Data block length ( =4+4*32*2 ).
buf Buffer in which the override amount are stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
EW_NOOPT( 6) There are no required options (Manual handle override).
[Description]
Reads the manual handle override amount of the CNC controlled axis.
This function is used for displaying the manual handle override amount
of the CNC's axis by the application program, etc.
Always specify -1 (all axes data) for the axis number in "axis",
and 260 (=4+4*32*2) for the data block length in "length".
The override amounts of the (i+1)th axis both in the input unit and
the output unit are stored in each data[0][i] and data[1][i].
The both are the same override amount though their units are
different.
[Example]
Assume that each axis of a three-axis system has a manual override
amount listed below:
Input unit Output unit
First axis 4.7246 120.005
Second axis -1.9732 -50.119
Third axis 0.0031 0.080
On the assumption stated above, the following program displays the
values listed below (on the assumption that the inch input, metric
output, and increment system conform to IS-B):
0: 47246 120005
1: -19732 -50119
2: 31 80
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
------------------------------------------------------------------------------
2.1 Read arbitrary PMC data (range specified). <Main,Alarm>
------------------------------------------------------------------------------
[Name]
pmc_rdpmcrng
[Syntax]
#include <data.h>
#include <fwindow.h>
short pmc_rdpmcrng( short adr_type, short data_type, short s_number,
short e_number, short length, struct iodbpmc *buf ) ;
struct iodbpmc {
short type_a ; /* Kind of PMC address. */
short type_d ; /* Type of PMC data. */
short datano_s ; /* Start PMC address. */
short datano_e ; /* End PMC address. */
union {
char cdata[N] ; /* PMC data (Byte) */
short idata[N] ; /* (Word) */
long ldata[N] ; /* (2-Word) */
} u ; /* N is number of data to be read. */
} ;
[Arguments]
adr_type Kind of PMC address.
data_type Type of PMC data.
s_number Start PMC address.
e_number End PMC address.
length Data block length
( =8+(byte size of data)*(number of data to be read)).
buf Buffer in which the PMC data are stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect PMC address "s_number" or "e_number".
EW_ATTRIB( 4) Incorrect kind of PMC address "adr_type" or type of
PMC data "data_type".
[Description]
Reads the PMC data within the specified address range.
Specify the start PMC address in "s_number" and the end one in
"e_number" with binary format.
For example, when 800 [msec] is set in T0010, 100 is read by this
fucntion.
[Example]
The following program reads and displays the feed rate override value
(G0012).
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
pmc_wrpmcrng
[Syntax]
#include <data.h>
#include <fwindow.h>
short pmc_wrpmcrng( short length, struct iodbpmc *buf ) ;
struct iodbpmc {
short type_a ; /* Kind of PMC address. */
short type_d ; /* Type of PMC data. */
short datano_s ; /* Start PMC address. */
short datano_e ; /* End PMC address. */
union {
char cdata[N] ; /* PMC data (Byte) */
short idata[N] ; /* (Word) */
long ldata[N] ; /* (2-Word) */
} u ; /* N is number of data to be written. */
} ;
[Arguments]
length Data block length
( =8+(byte size of data)*(number of data to be
written) ).
buf Buffer in which the PMC data are stored.
[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect PMC address "buf.datano_s" or "buf.datano_e".
EW_ATTRIB( 4) Incorrect kind of PMC address "buf.type_a" or type of
PMC data "buf.type_d".
[Description]
Writes the PMC data within the specified address range.
Specify the start PMC address in "buf.datano_s" and the end one in
"buf.datano_e" with binary format.
Store the written data in one of "buf.u.cdata[i]", "buf.u.idata[i]"
or "buf.u.ldata[i]" according to its type.
For example, when you want to set 800 [msec] in T0010, specify 100
in this fucntion.
(Caution) When this function is used to write PMC data, it does not perform
exclusive control for the PMC ladder. When both an application
program and PMC ladder are expected to write to the same PMC address,
therefore, the application program must perform exclusive control.
When writing to a PMC address especially bit by bit, you should avoid
allowing both program entities to write simultaneously. This is
because the NC and PMC processors operate asynchronously to each
other.
Example of arguments specification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(1) Writing 250 to "D0100" (Word type data).
buf.type_a 9 or 'D'
buf.type_d 1
buf.datano_s 100
buf.datano_e 101
length 8+2*1 (=10)
buf.u.idata[0] 250
[Example]
The following program sets the specified bit of a specified internal
relay (R) to "1".
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
[Name]
pmc_rdpcmsg
[Syntax]
#include <data.h>
#include <fwindow.h>
short pmc_rdpcmsg( unsigned short adr_no, unsigned short adr_bit,
struct pmcmsg *buf ) ;
struct pmcmsg {
unsigned short msg_len ; /* Length of message. */
unsigned char pmc_msg[256] ; /* PMC message string. */
} ;
[Arguments]
adr_no PMC address A. ( =0 - 24 )
adr_bit Bit of PMC address A. ( =0 - 7 )
buf Buffer in which PMC message is stored.
[Return]
EW_OK( 0) Successful.
EW_NUMBER( 3) Incorrect PMC address A.
EW_ATTRIB( 4) Incorrect bit of PMC address A.
EW_DATA( 5) No message for specified address.
[Description]
Reads the specified PMC message data.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>
Library outline
~~~~~~~~~~~~~~~
1. Outline
The application program can control the MDI-KEY using the MDI operation
library.
The MDI Key matrix consists of the key function table which defines key
attributes and the key code table which defines key codes. There are both
matrix for the user application program and one for CNC software.
The relationship of the MDI key bit matrix and the MDI key matrix is as
follows.
Each words of the key code table include both "Main code" and "Sub code".
It is impossible to push the SHIFT key and any ordinary keys simultaneously.
To input sub code, operate as following sequence.
Push the SHIFT key, and then release it.
Push any ordinary key.
(2) Structure of function flag
The function flag is one byte flag which defines attributes of key for every
key. This flag defines following items bit by bit.
(3) Uppercase/Lowercase
(1) Functions
The application program can send an arbitrary character or string to the key
input buffer of the MDI-KEY by calling following functions.
These character and string are received regardless of any operation to the
screen or MDI panel.
(2) Arguments
The application program sends a pair of the function flag and the key code to
be output to the above functions. The format of the function flag is same as
the MDI key matrix. Any arbitrary value is allowed to be specified for key
code. Also any key code which isn't registered in the standard key matrix. (It
is possible to send a key code as a message from any auxiliary task to the main
task.)
The key input from the application program is handled more preferentially
than one from the MDI panel. Therefore, when any key is input from both the
application and the MDI panel simultaneously, the former is given to the
software. Usually, inhibit the key input from the MDI panel during inputting
key from the application program using following functions.
MDI operation library of C Library can handle only key information input
to C User application. C User application can execute all MDI operation
library functions. However, only operations for the key inputting to the
user application is effective. It is impossible to operate key inputting
information to the CNC software by specifying MAIN_MDI_MATRIX for each
function. (No error is issued.)
The Open-CNC application execute the operations for key inputting information
to the CNC software and the Open-CNC application software.
The Intelligent Terminal application execute all of the operations for key
inputting information.
Lists of Functions
~~~~~~~~~~~~~~~~~~
----------------------------------------------------------------------
Name Function
----------------------------------------------------------------------
1. aux_mdi_getmatrix Get MDI key matrix.
2. aux_mdi_putmatrix Put MDI key matrix.
3. aux_mdi_rstmatrix Reset MDI key matrix.
4. aux_mdi_altmatrix Alter MDI key matrix.
5. aux_mdi_putc Put one character to key input buffer.
6. aux_mdi_write Write block data to key input buffer.
7. aux_mdi_control Test or control key input buffer.
8. aux_mdi_repeat Set key repeating interval time.
9. aux_mdi_getstat Read inputting status of MDI key.
10. aux_mdi_clrbuf Clear input buffer of MDI key.
----------------------------------------------------------------------
------------------------------------------------------------------------------
1. Get MDI key matrix. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
aux_mdi_getmatrix
[Syntax]
#include <bios.h>
int aux_mdi_getmatrix( void *matrix_ptr, int matrix_len,
int module_id ) ;
[Arguments]
matrix_ptr Buffer in which key matrix is stored.
matrix_len Byte size of key matrix buffer.
module_id Class of matrix.
[Return]
0 Successful.
-1 Incorrect byte size of key matrix buffer "matrix_len". Or
incorrect class of matrix "module_id".
[Description]
Reads the current key matrix (function flag table and key code table)
of MDI key, and stores them in the specified buffer.
This function is used to read the original key matrix for altering the
part of the key matrix.
Get the required table size of the key matrix before calling this
function, and allocate buffer area for reading.
------------------------------------------------------------------------------
2. Put MDI key matrix. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
aux_mdi_putmatrix
[Syntax]
#include <bios.h>
int aux_mdi_putmatrix( void *matrix_ptr, int matrix_len,
int module_id ) ;
[Arguments]
matrix_ptr Buffer in which key matrix is stored.
matrix_len Byte size of key matrix buffer.
module_id Class of matrix.
[Return]
0 Successful.
-1 Incorrect byte size of key matrix buffer "matrix_len". Or
incorrect class of matrix "module_id".
[Description]
Registers the specified key matrix as the new matrix.
[Name]
aux_mdi_rstmatrix
[Syntax]
#include <bios.h>
int aux_mdi_rstmatrix( int module_id ) ;
[Arguments]
module_id Class of matrix.
[Return]
0 Successful.
Negative Incorrect class of matrix "module_id".
[Description]
Restore the MDI key matrix to the initial (power-on) setting.
This function is used to restore te MDI key matrix which is modified
by "aux_mdi_putmatrix" function to the initial setting.
[Name]
aux_mdi_altmatrix
[Syntax]
#include <bios.h>
int aux_mdi_altmatrix( int module_id, int category, int update ) ;
[Arguments]
module_id Class of matrix.
category Kind of key to be altered.
update New specification.
[Return]
0 Successful (No alteration was applied.).
Positive Successful ("Positive" is number of applied alteration.).
-1 Incorrect class of matrix "module_id".
-2 Incorrect kind of key to be altered "category".
-3 Incorrect new specification "update".
-4 Incorrect "MDI_SHIFT_xx" specification.
-5 Incorrect "MDI_TO_xx" specification.
-6 Incorrect "MDI_REPEAT_xx" specification.
-7 Attempted to alter the RESET key.
[Description]
Alters character code or character attribute which is assigned to the
specified MDI key.
This function is used to alter character code assigned to the key or to
enable automatic key repeating of the cursor key or the page key, etc.
[Name]
aux_mdi_putc
[Syntax]
#include <bios.h>
int aux_mdi_putc( int c ) ;
[Arguments]
c Output data.
[Return]
1 Successful.
0 Key input buffer is full.
[Description]
Output the specified 1-byte character to the key input buffer.
Specify a function flag in the upper byte of "c" and a character code
in the lower byte. For example, specify as follows to output 'A'.
upper byte <- 0x20 (function flag)
lower byte <- 0x41 (character code)
This function outputs data to the key input buffer. Check buffer
emptiness by calling "aux_mdi_control" function to confirm completion
of outputting data from the buffer.
------------------------------------------------------------------------------
6. Write block data to key input buffer. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
aux_mdi_write
[Syntax]
#include <bios.h>
int aux_mdi_write( void *buffer, int size ) ;
[Arguments]
buffer Buffer in which the output data are stored.
size Byte size of output data.
[Return]
Positive Successful. (Byte size of actually output data.)
This value will be smaller than the specified size in case that
there are not enough room for specified size in the key input
buffer.
0 Key input buffer is full.
[Description]
Output data for specified byte size from the specified buffer to the
key input buffer.
[Name]
aux_mdi_control
[Syntax]
#include <bios.h>
int aux_mdi_control( int control ) ;
[Arguments]
control Control code.
[Return]
(1) In case of successful.
MDI_CHK_BUF Returns number of data in the buffer.
MDI_GET_MTXLEN Returns byte size of MDI key matrix.
MDI_CASE_ON Returns the previous status.
MDI_CASE_OFF Returns the previous status.
MDI_CHK_FKEY Returns the key code of pushed function key.
Others Returns "0".
[Description]
Test the key input buffer, or execute specified operation to the key
input buffer.
control Operation
---------------+--------------------------------------------
MDI_CHK_BUF Returns number of data in the application key
input buffer.
MDI_CLR_BUF Clears the application key input buffer.
MDI_LOK_PNL Locks MDI key input except RESET key.
MDI_ULK_PNL Unlocks MDI key input.
MDI_GET_MTXLEN Return byte size of the MDI key matrix table.
MDI_CASE_ON Enables uppercase/lowercase character input
from the MDI panel.
MDI_CASE_OFF Disables uppercase/lowercase character input
from the MDI panel.
MDI_CHK_FKEY If the screen switching was disabled while any
user screen was displaying for some reason and
any function key was pushed during disabling
screen switching, returns key code of that
function key.
Returns 0 if no function key was pushed while
the screen switching was disabled.
------------------------------------------------------------------------------
8. Set key repeating interval time. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
aux_mdi_repeat
[Syntax]
#include <bios.h>
int aux_mdi_repeat( int delay, int repeat ) ;
[Arguments]
delay Delay time of automatic repeating.
repeat Interval time of automatic repeating.
[Return]
0 Successful.
-1 Incorrect delay time "delay".
-2 Incorrect interval time "repeat".
[Description]
Set the delay time and the interval time of automatic key repeating.
[Name]
aux_mdi_getstat
[Syntax]
#include <bios.h>
unsigned int aux_mdi_getstat( void ) ;
[Arguments]
------
[Return]
Returns inputting status of MDI key.
[Description]
Gets the inputting status of MDI key.
Each bits of returned value mean following information.
That is, once pushing [SHIFT] key makes "SHIFT state" ON, then,
pushing any other key makes "SHIFT state" released. Pushing [SHIFT]
key again during "SHIFT state" makes "SHIFT released.
It is impossible to input Sub code by pushing any key and [SHIFT] key
simultaneously.
This function gets the status of key input buffer while the
C Executor's user screen is being displayed. It can't get the status
of the key input buffer of the CNC software.
[Example]
The following program reads a line of alpha-numeric characters from
the MDI panel. Inputting operation is completed by inputting
[INPUT] key. It displays one of '_' (in normal state) and '^' as
cursor.
#include <bios.h>
#include <ctype.h>
#include <stdio.h>
#define BUFSIZE 80
unsigned char buf[BUFSIZE] ;
[Name]
aux_mdi_clrbuf
[Syntax]
#include <bios.h>
void aux_mdi_clrbuf( void ) ;
[Arguments]
------
[Return]
------
[Description]
Clears input buffer of MDI key.
This function clears all characters which are input from MDI panel
and not read by the application program yet, and makes "SHIFT state"
at the same time.
This function makes no effects to the key input buffer of the CNC
software.
Key code table
~~~~~~~~~~~~~~
The following are the key code table of various keyboard which are supported
by C Executor. Lines and columns of "Key bit matrix", "Key function flag table"
and "Key code table" are correspond each other in every keyboard.
For example, to get key code and function flag for C application of "X" key
in the machining system's full key, search as follows.
(1) Search "X" key in "Key bit matrix". (7th line, 4th column)
(2) See the 7th line and 4th column of "Key function flag table" and
"Key code table" for C application.
(3) You get 0x10 for key function flag and "58 55" for key code.
This means that a code 0x58 will be generated by pushing "X" key
individually, and 0x55 by pushing SHIFT + "X".
To change this function flag and key code, do as follows.
Setting bit 2 (EKY) of parameter No. 8650 in the NC to 1 causes the key BIOS of
the C executor to scan the extension MDI keys. If a user application assigns
key codes to the extension of the key matrix, the assigned keys can be read.
(If no key code is specified, it is impossible to read the extension keys.)
+---------------------------------------+
| 80-column |
| |
| |
| |
| |
| |
|25-line (or 30-line) |
| |
| |
| |
| |
| |
| |
+---------------------------------------+
[L] [0][1][2][3][4] [5][6][7][8][9] [R] <- 12 softkeys (10+2)
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
1.1 crt_getcurscrn Get current screen index.
1.2 crt_setuserscrn Register user screen index.
1.3 crt_isnewscrn Test screen switching status.
1.4 crt_gettype Get CRT information.
1.5 crt_setmode Set CRT screen mode.
1.6 crt_cncscrn Switch to CNC screen.
1.7 crt_fchar Output character by FANUC character code.
1.8 crt_setuserskey Customize softkey on CNC screen.
1.9 crt_setswt Set switching method between CNC's screen and
user's.
1.10 crt_setscrlarea Set scroll area.
1.11 crt_opengr Open graphic display.
1.12 crt_closegr Close graphic display.
1.13 crt_graphic Enable or disable graphic display.
1.14 crt_readfkey Read the status of function keys.
1.15 crt_2ndcursor Display the secondary cursor.
1.16 crt_settextattr Set attribute of characters on VRAM.
1.17 crt_gettextattr Get attribute of character on VRAM.
1.18 crt_setpalette Set color palette of VGA characters.
1.19 crt_setallpalette Set all color palette of VGA characters.
1.20 crt_getcncpalette Get color palette of CNC screen.
1.21 crt_fstr Output character string by FANUC character
code.
1.22 crt_gettextimg Get text data from VRAM.
1.23 crt_puttextimg Put text data into VRAM.
1.24 crt_setgraphpage Select graphic page to use.
1.25 crt_set6chmode Select drawing method of 6x sized character.
1.26 crt_setgsvmode Select saving method of graphic contents.
--------------------------------------------------------------------------
2. Multiple window display library
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
2.1 win_open Open window.
2.2 win_close Close window.
2.3 win_select Select window.
2.4 win_activate Activate window.
2.5 win_move Move window.
2.6 win_size Alter window size.
2.7 win_full Let active window be full screen size.
2.8 win_window Let active window be window size.
2.9 win_info Get window information.
2.10 win_col Set color of window frame and title string.
2.11 win_hide Hide window.
2.12 win_show Show window.
2.13 win_setttl Set window title string.
2.14 win_setfrm Set window frame line character.
2.15 win_getstat Get window display status.
2.16 win_redraw Redraw windows.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
3.1 crt_reguserchar Register user character.
3.2 crt_mapuch Map user character.
3.3 crt_getcgpttn Get CG pattern.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
4.1 vwin_open Open VGA window.
4.2 vwin_close Close VGA window.
4.3 vwin_select Select VGA window.
4.4 vwin_show Show VGA window.
4.5 vwin_hide Hide VGA window.
4.6 vwin_info Get VGA window information.
--------------------------------------------------------------------------
Function Reference
~~~~~~~~~~~~~~~~~~
------------------------------------------------------------------------------
1.1 Get current screen index. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
crt_getcurscrn
[Syntax]
#include <crt.h>
int crt_getcurscrn( void ) ;
[Arguments]
------
[Return]
Returns the index number of the currently displayed screen.
[Description]
Gets the index number of the currently displayed screen.
#include <crt.h>
#include <stdio.h>
[Name]
crt_setuserscrn
[Syntax]
#include <crt.h>
int crt_setuserscrn( int num, int *scrntbl ) ;
[Arguments]
num Number of screen index to be registered.
scrntbl Pointer to the user screen index table.
[Return]
Returns zero if successful. If any error, returns -1 and sets the
following error code in the global variable "errno".
EUCRT Number of the screen index "num" is 0 or above 200.
[Description]
Registers the screen index numbers of the CNC screens which is
replaced by the user application program.
The index numbers of the user screens are registered in CNC by calling
of this function. Then, the user application will be called by
selection of registered screens.
Store the screen index numbers in "scrntbl" with the following format.
The storing order is arbitrary.
Refer the screen index number list of "Get current screen index
(crt_getcurscrn)" for index numbers of each screens. All available
index values are defined in crt.h as "CRT_xxx_xxx".
[Example]
The following program registers all position screens
([ALL]/[REL]/[ABS]/[MCN]) as user's screen.
#include <crt.h>
[Name]
crt_isnewscrn
[Syntax]
#include <crt.h>
int crt_isnewscrn( void ) ;
[Arguments]
------
[Return]
Returns non-zero value if any screen switching has been done after
the last calling this function. If not, returns zero.
[Description]
Test whether any screen switching has been done or not.
This function is used to check the new entrance to the user screen
by screen switching such as
(any user screen) -> (CNC screen) -> (the same user screen).
In this case, it is impossible to get screen switching status by only
calling "crt_getcurscrn" function.
[Example]
The following program displays whether any screen switching has been
done or not.
#include <crt.h>
#include <stdio.h>
void example( void )
{
if ( crt_isnewscrn() )
printf( "Any" ) ;
else
printf( "No" ) ;
printf( " screen switching has been done.\n" ) ;
}
------------------------------------------------------------------------------
1.4 Get CRT information. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
crt_gettype
[Syntax]
#include <crt.h>
unsigned int crt_gettype( void ) ;
[Arguments]
------
[Return]
Returns CRT information.
[Description]
Gets the equipped CRT specification and the current display mode.
This function is used to get whether CRT is 9 inch or 14 inch, etc.
[Example]
The following program displays information of the current display
equipment.
#include <crt.h>
#include <stdio.h>
[Name]
crt_setmode
[Syntax]
#include <crt.h>
int crt_setmode( unsigned int mode ) ;
[Arguments]
mode CRT screen mode.
[Return]
Returns zero if successful. If any error, returns non-zero value.
[Description]
Set the screen mode such as character size and color/monochrome mode.
The screen mode is changed into the specified one and the screen is
initialized by the successful calling of this function.
+---------------------------------+
+- | Blank of n lines |
| |---------------------------------|
| |Start line ^ | -+
| | | | |
| | | | |
30 lines | | | | |
(19 lines)| | | Display region | | 25 lines
| | | | |(16 lines)
| | | | |
| | | | |
| | | | |
| | v | -+
+- |---------------------------------|
+---------------------------------+
[Name]
crt_cncscrn
[Syntax]
#include <crt.h>
int crt_cncscrn( int index ) ;
[Arguments]
index Index number of the CNC screen to be switched to.
[Return]
Returns zero if successful. If not, returns one of following values
and sets the same value in the global variable "errno".
[Description]
Changes into the CNC screen which is specified by the application
program. Also execution of program is switched from the application
task to the CNC task. This is the same operation as switching to CNC
screen by pressing of the function keys on MDI panel.
The CRT display will be switched into the specified CNC screen by
the successful calling of this function.
At the same time, the control of software will be switches to the
CNC side, and then, the application program is put into sleep state.
When the screen will be changed from the CNC side into the user's
screen again, the application program will restart from the next
instruction to this function call.
Specify the screen index numbers in "index" with the following format.
#include <crt.h>
#include <data.h>
#include <fwindow.h>
[Name]
crt_fchar
[Syntax]
#include <crt.h>
int crt_fchar( unsigned int code ) ;
[Arguments]
code FANUC character code ( 0x0000 through 0x1fff ),
or FANUC character code | 0x8000 (0x8000 through 0x9fff).
[Return]
Returns always zero.
[Description]
Outputs a character that is included in FANUC character set and is
specified by FANUC character code on the current cursor position.
#include <crt.h>
#include <stdio.h>
#include <string.h>
[Name]
crt_setuserskey
[Syntax]
#include <crt.h>
int crt_setuserskey( unsigned int index, unsigned int num,
struct user_softkey *skey ) ;
struct user_softkey {
unsigned int index ; /* Softkey index number. */
int op ; /* Operation code. */
unsigned int submode ; /* Small classification of */
/* user's screen. */
unsigned int *string ; /* Display string. */
} ;
[Arguments]
index Softkey table index number to be customized.
num Number of customizing item.
skey Customizing data table.
[Return]
Returns zero if successful. If any error, returns -1 and sets the
following error code in the global variable "errno".
[Description]
Alters the softkey displayed on the CNC screen as follows, adds new
items, by which any user screens are selected, moves the existent
items, by which the CNC screens are selected,deletes the existent
items.
Specify the softkey table index number to be customized in "index".
There are the softkey tables for each large classifications of the CNC
screen (and more, for each modes in the PROGRAM screen).
All available table index values are defined in crt.h as "SKEY_xxxx".
Store multiple customizing data in "skey".
The customizing data includes the following items.
POSITION
[ ABS ][ REL ][ ALL ][ HANDLE ][ ]
[ MONITOR ][ 5AXMAN ][ ][ ][ ]
[ CEXE ][ CEXE2 ][ CEXE3 ][ CEXE4 ][ CEXE5 ]
[01][02][03][04][ ]
[06][07][ ][ ][ ]
[50][51][52][53][54]
PROGRAM
[ PROG ][ FOLDER ][ NEXT ][ CHECK ][ ]
[ RSTR ][ JOG ][ ][ ][ ]
[ HOST ][ CONECT ][ ][ ][ ]
[ CEXE ][ CEXE2 ][ CEXE3 ][ CEXE4 ][ CEXE5 ]
[01][02][03][04][ ]
[06][07][ ][ ][ ]
[11][12][ ][ ][ ]
[50][51][52][53][54]
OFFSET/SETTING
[ OFFSET ][ SETTING ][ WORK ][ ][ ]
[ MACRO ][ ][ OPR ][TOOL MANAGER][ ]
[ OFST.2 ][ W.SHFT ][ GEOM.2 ][ TOOL.F ][ ]
[ MODEM ][ PR-LEV ][ ][ CHOP ][ ]
[ CHUCK TAIL ][ LANG. ][ PROTECT ][ GUARD ][ ]
[ CEXE ][ CEXE2 ][ CEXE3 ][ CEXE4 ][ CEXE5 ]
[01][02][03][ ][ ]
[06][ ][08][09][ ]
[11][12][13][14][ ]
[16][17][ ][19][ ]
[21][22][23][24][ ]
[50][51][52][53][54]
(continued)
SYSTEM
[ PARAM ][ DGNOS ][SERVO GUIDEM][ SYSTEM ][ ]
[ MEMORY ][ PITCH ][ SV-PRM ][ SP.SET ][ ]
[ PMC MAINTE ][ PMC LADDER ][ PMC CONFIG ][ ][ ]
[ M-TUN ][ ALL IO ][ ALL IO ][ OPEHIS ][ ]
[ COLOR ][ MAINTE ][ M-INFO ][ W.DGNS ][ ]
[ ][ FSSB ][ PRMTUN ][ ][ ]
[ EMBED PORT ][ PCMCIA LAN ][ETHER BOARD ][PROFI MASTER][ ]
[ RMTDGN ][ M CODE ][ ][ ][ ]
[ CEXE ][ CEXE2 ][ CEXE3 ][ CEXE4 ][ CEXE5 ]
[01][02][03][04][ ]
[06][07][08][09][ ]
[11][12][13][ ][ ]
[16][17][18][19][ ]
[21][22][23][24][ ]
[ ][27][28][ ][ ]
[31][32][33][34][ ]
[36][37][ ][ ][ ]
[50][51][52][53][54]
MESSAGE
[ ALARM ][ MSG ][ HISTRY ][ MSGHIS ][ ]
[ EMBED LOG ][ PCMCIA LOG ][ BOARD LOG ][ ][ ]
[ CEXE ][ CEXE2 ][ CEXE3 ][ CEXE4 ][ CEXE5 ]
[01][02][03][04][ ]
[06][07][08][ ][ ]
[50][51][52][53][54]
GRAPH
[ PARAMETER ][ GRAPH ][ ][ ][ ]
[ CEXE ][ CEXE2 ][ CEXE3 ][ CEXE4 ][ CEXE5 ]
[01][02][ ][ ][ ]
[50][51][52][53][54]
How to define display string of the softkey
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(1) Define array of "int" type(or "unsigned int" type). The total number
of elements is 12( 6 characters x 2-line). The exceeded elements are
ignored.
#include <crt.h>
void example( void ) {
unsigned int skey_str[] = {
0x0020,0x0055,0x0053,0x0045,0x0052,0x0020, /* " USER " */
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020 /* " " */
} ;
struct user_softkey skey_table[] = {
{ 4, SKEY_OP_DEL, 0, NULL },
{ 2, 1, 0, NULL },
{ 1, SKEY_OP_USER, 3, skey_str }
} ;
crt_setuserskey( SKEY_POSITION, skey_tbl_size(skey_table),
skey_table ) ;
}
------------------------------------------------------------------------------
1.9 Set switching method between CNC's screen and user's. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
crt_setswt
[Syntax]
#include <crt.h>
unsigned int crt_setswt( unsigned int mode ) ;
[Arguments]
mode Screen switching mode.
[Return]
Returns the old setting value.
[Description]
Set switching method such as,
disable/enable to switch to the CNC screen from the user's,
disable/enable to output video signal at switching to the user
screen from the CNC's.
When the application program manages the screen switching with setting
this bit ON, set CNC parameter No.8650#1 CNA as "1" and manages also
screen switching at CNC alarm rising by the application program.
[Example]
The following program disables screen switching, executes foo()
function and restores the original status again.
#include <crt.h>
void example( void )
{
unsigned int save_mode ;
save_mode = crt_setswt( CRT_SWT_DIS ) ;
foo() ;
crt_setswt( save_mode ) ;
}
------------------------------------------------------------------------------
1.10 Set scroll area. <Main>
------------------------------------------------------------------------------
[Name]
crt_setscrlarea
[Syntax]
#include <crt.h>
int crt_setscrlarea( unsigned int start, unsigned int height ) ;
[Arguments]
start Start line of the scroll area (1 - max line).
height Height of the scroll area (1 - max line).
[Return]
Returns zero if successful. If any error (for example, the scroll area
is out of the screen, etc.), returns "1".
[Description]
Set the scroll area for automatic scrolling by line-feeding.
[Example]
The following program sets the scroll area in 2 through 24th line.
(The top line and the bottom line are not scrolled.)
#include <crt.h>
[Name]
crt_opengr
[Syntax]
#include <crt.h>
int crt_opengr( void ) ;
[Arguments]
------
[Return]
Returns "0" or "1" if successful. If any error (Graphic board is not
equipped, or the graphic function option is not set.), returns "-1".
The difference between return code "0" and "1" is as follows.
0 The authorization to use graphic display has not been
given to another application after the last calling
of crt_closegr() function. So, initialization of
graphic screen is not required because the state of
graphic display on the last calling of crt_closegr()
is being kept.
1 The authorization to use graphic display has been
given to another application after the last calling of
crt_closegr() function. So, initialization of graphic
screen is required because the state of graphic
display on the last calling of crt_closegr() is not
being kept.
[Description]
Acquire authorization to use graphic display and become ready for the
graphic display.
[Example]
Following program draws a line defined by two specified end points.
#include <crt.h>
#include <graph.h>
[Name]
crt_closegr
[Syntax]
#include <crt.h>
void crt_closegr( void ) ;
[Arguments]
------
[Return]
------
[Description]
Stop using graphic display and become ready to release authorization
for graphic display.
[Example]
Refer to the example of "Open graphic display (crt_opengr)".
------------------------------------------------------------------------------
1.13 Enable or disable graphic display. <Main,Alarm>
------------------------------------------------------------------------------
[Name]
crt_graphic
[Syntax]
#include <crt.h>
int crt_graphic( int mode ) ;
[Arguments]
mode Specify graphic output ON or OFF.
[Return]
Returns zero if successful and returns non zero if any error (graphic
function is not ready for use).
[Description]
Specify whether to display graphics on the CRT or not (GRAPHIC BEAM
ON or OFF).
Graphics can be drawn even while the display of the graphics to the
CRT is disabled.
The default state of the "GRAPHIC BEAM" right after the graphic screen
is initialized (i.e. when returned from the "_setvideomode" function)
is "ON".
Screen switching from the user screen to the CNC screen automatically
turns the "GRAPHIC BEAM" off. After switching the screen to the user's
again, turn the "GRAPHIC BEAM" on by this function to get graphic
display on the CRT.
[Example]
Following program tests the current screen, and turns the
"GRAPHIC BEAM" on if it is POSITION display screen. Turns the
"GRAPHIC BEAM" off if else.
#include <crt.h>
[Name]
crt_readfkey
[Syntax]
#include <crt.h>
int crt_readfkey( void ) ;
[Arguments]
------
[Return]
Returns zero if no function keys are depressed or CRT_SWT_MFKY bit of
the "crt_setswt" function is set to "0". When CRT_SWT_MFKY bit is set
to "1", keycode for the function key being depressed is returned.
Keycodes are shown below.
[Description]
This function reads the status of the function keys on the MDI panel,
and is used by the user application program to switch screens
according to the status of the function keys.
#include <crt.h>
#include <oscall.h>
for (;;) {
os_wait_tim( 5 ) ; /* run every 40msec */
curscrn = crt_getcurscrn() ; /* get current screen index */
/* number */
savescrn[curscrn % 0x100] = curscrn ;
/* save index including small classification */
if ( fkey = crt_readfkey() ) {
/* if function key is pressed */
/* restore previous small classification number */
newscrn = savescrn[fkey - MDIKEY_POS] ;
if ( newscrn != curscrn ) {
crt_cncscrn( newscrn ) ;
crt_setswt( CRT_SWT_MFKY ) ;
}
}
}
}
------------------------------------------------------------------------------
1.15 Display the secondary cursor. <Main>
------------------------------------------------------------------------------
[Name]
crt_2ndcursor
[Syntax]
#include <crt.h>
int crt_2ndcursor( unsigned int attrib, unsigned int start,
unsigned int end, unsigned int position,
unsigned int width ) ;
[Arguments]
attrib cursor attribute
start cursor start raster
end cursor end raster
position cursor position
width cursor width
[Return]
Returns zero if successful and returns "-1" if any error( invalid
argument).
[Description]
The crt_2ndcursor() sets cursor display ON/OFF or other attributes for
the 2nd cursor. The 2nd cursor is a cursor which can freely be
controlled by the user application program independent of the usual
character cursor.
The 2nd cursor is set to OFF(non display) state, after the screen is
initialized by crt_swtmode() function or "ESC [2J". Other than these
two methods, crt_2ndcursor() is the only means to control ON/OFF of
the 2nd cursor.
Specify following values for each arguments in binary form.
argument
------------+-------------------+-------------------------------
start 0 - 15
end 0 - 15
(must satisfy end>=start)
position 0 - 2399
width 1 - 80
[Example]
Following program modifies the specified lines to be underlined.
#include <crt.h>
[Name]
crt_settextattr
[Syntax]
#include <crt.h>
int crt_settextattr( unsigned int y1, unsigned int x1,
unsigned int y2, unsigned int x2,
unsigned int attr, unsigned int op ) ;
[Arguments]
y1 Line number of the upper-left position of the
attribute setting region.
x1 Column number of the upper-left position of the
attribte setting region.
y2 Line number of the lower-right position of the
attribute setting region.
x2 Column number of the lower-right position of the
attribute setting region.
attr Set attribute value.
op Logical operation specification.
[Return]
Returns zero if successful. If any error (incorrect coordinate spec
or incorrect logical operation spec), returns non-zero value.
[Description]
Sets the specified attributes to the characters displayed on the
screen. This function doesn't change the already displayed character
code but changes only its attributes.
Specify line and column number of the upper-left and the lower-right
position in "y1", "x1" and "y2", "x2". (The upper-left position of
the screen is (1st-column, 1st-line).)
+-----------------------------------+
|(1,1) Whole screen|
| |
| +-------------------+ |
| |(y1,x1) | |
| | | |
| | | |
| | (y2,x2)| |
| +-------------------+ |
| Attribute setting region |
| |
| (ymax,xmax)|
+-----------------------------------+
ymax=30, xmax=80
15 8 7 0
+------------------------+------------------------+
| 0 0 0 Ib Bb Gb Rb I | B G R r b 0 0 0 |
+------------------------+------------------------+
B: Blue r: Reverse
G: Green b: Blink
R: Red
I: Low intensity
Bb:Background Blue
Gb:Background Green
Rb:Background Red
Ib:Background Low intensity
#include <crt.h>
[Name]
crt_gettextattr
[Syntax]
#include <crt.h>
unsigned int crt_gettextattr( unsigned int y, unsigned int x ) ;
[Arguments]
y Line position of the character to be got the
attribute.
x Column position of the character to be got the
attribute.
[Return]
Returns the attribute of the character at the specified position.
If incorrect position specification, returns -1.
[Description]
Gets the attribute of the character at the specified position.
[Example]
The following program reads the attribute of the character at
(3rd-line, 30th-column) of the screen.
#include <stdio.h>
#include <crt.h>
[Name]
crt_setpalette
[Syntax]
#include <crt.h>
#include <graph.h>
int crt_setpalette( unsigned int index, unsigned long color ) ;
[Arguments]
index Index of color palette. (0..15,_PAL_COMP,_PAL_RVS)
color Color value.
[Return]
Returns zero if successful. If any error (incorrect color palette
index or not a VGA display device), returns non-zero value.
[Description]
Sets the color value to the color palette for character.
Specify the color palette index number (0..15) in "index" and the
color value in "color". The format of the color value specified in
"color" is same as the color value used in a graphic function
"_remappalette". (The symbols of the color value defined in the
header file "graph.h" such as _98GREEN are available for "color"'s
specification.)
32 0
+--------+--------+--------+--------+
|00000000|00BBBBBB|00GGGGGG|00RRRRRR|
+--------+--------+--------+--------+
R Red data (Lower byte)
G Green data (2nd byte)
B Blue data (3rd byte)
Each data mean the intensity of each color in range 0x00 - 0x3F.
The larger value means more intensity color.
Once "low intensity (dark)" mode is set by "ESC [1m" or "ESC [3m",
all of the following color specifications are assumed to be low
intensity. For example,
For LCD device, the lower 2 bits of each color are masked. That is,
0x00,0x04,0x08,..,0x3C are valid setting value for each color.
Even if the application program specifies "1" at the lower 2 bits,
the VGA firmware masks them. (In this case, max.4,096 colors are
representable.)
Character Graphics
palette index palette index Dot color
---------------+---------------+---------------+----------------
Composite 0 0 Composite color
Not 0 0 Composite color
0 Not 0 Composite color
Not 0 Not 0 Composite color
---------------+---------------+---------------+----------------
Character 0 0 Graphic color
over Graphics Not 0 0 Character color
0 Not 0 Graphic color
Not 0 Not 0 Character color
---------------+---------------+---------------+----------------
Graphics 0 0 Character color
over Character Not 0 0 Character color
0 Not 0 Graphic color
Not 0 Not 0 Graphic color
This table indicates that the palette index 0 is the special part
for overlapping the character and the graphics. Allocate "Black"
to the palette 0 as same as initial value so far as there are no
exceptional reasons.
[Name]
crt_setallpalette
[Syntax]
#include <crt.h>
#include <graph.h>
int crt_setallpalette( unsigned long *colors ) ;
[Arguments]
colors Pointer to the color value array.
[Return]
Returns zero if successful. If any error (not a VGA display device),
returns non-zero value.
[Description]
Sets the color values to the all color palette for character.
This function doesn't affect the color palettes of the other screen
and the color palettes of graphics.
All palette are set as the system initial values by specifying NULL
in "color". The system initial values is listed in the description of
"crt_setpalette" function.
------------------------------------------------------------------------------
1.20 Get color palette of CNC screen. <Main>
------------------------------------------------------------------------------
[Name]
crt_getcncpalette
[Syntax]
#include <crt.h>
int crt_getcncpalette( unsigned long *cnccol ) ;
[Arguments]
cnccol Color palette table of CNC screen. (32 elements)
[Return]
Returns zero if successful. If any error (one of following cases),
returns non-zero value.
- Not VGA display device.
[Description]
Gets the color palette setting values of the CNC screen.
This function is used to display the user's screen with the same
color as the CNC's screen or to get the colors of the base CNC screen
by the window task.
The color palette values of the CNC screen are stored in "cnccol" as
follows
[Example]
The following program sets all color palettes as same as the CNC's
screen.
#include <crt.h>
#include <graph.h>
if ( !crt_getcncpalette( cnccol ) ) {
crt_setallpalette( &cnccol[0] ) ;
_remapallpalette( &cnccol[16] ) ;
}
}
------------------------------------------------------------------------------
1.21 Output character string by FANUC character code. <Main>
------------------------------------------------------------------------------
[Name]
crt_fstr
[Syntax]
#include <crt.h>
int crt_fstr( unsigned int *code, unsigned int len ) ;
[Arguments]
code Array of FANUC character code ( 0x0000 - 0xffff ).
len Length of the character string.
[Return]
Returns always zero.
[Description]
Outputs a character string that is included in FANUC character set
and is specified by FANUC character code on the current cursor
position.
unsigned int i ;
for ( i = 0 ; i < len ; i++ )
crt_fchar( code[i] ) ;
[Example]
The following program displays an icon of a tester on the current
cursor position.
#include <crt.h>
[Name]
crt_gettextimg
[Syntax]
#include <crt.h>
int crt_gettextimg( unsigned int y1, unsigned int len x1,
unsigned int y2, unsigned int len x2,
unsigned long *buf ) ;
[Arguments]
y1 Left,upper position of the area from where characters are
got.
x1 Left,lower position of the area from where characters are
got.
y2 Right,lower position of the area from where characters are
got.
x2 Right,upper position of the area from where characters are
got.
buf Area that characters data are stored.
[Return]
Returns zero when terminated normally, not zero when error, i.e.
specified coordinates is not correct, is occurred.
[Description]
Gets character codes, displayed on the screen, with their attribute.
+-----------------------------------+
|(1,1) Full screen |
| |
| +-------------------+ |
| |(y1,x1) | |
| | | |
| | | |
| | | |
| | (y2,x2)| |
| +-------------------+ |
| Area for getting character |
| |
| |
| (ymax,xmax)|
+-----------------------------------+
ymax=30, xmax=80
(The characters which are enclosed in above area)*4 bytes area must
be reserved as "BUF". The data form, stored in "BUF", is as follows.
The character code is FANUC character code, and the type of the
attribute is explained the same as that of "crt_settextattr". The
position on the memory is corresponding to the position on the screen
as follows.
Position on the memory Position on the screen
-------------------------------+---------------------------
buf+0 y1 , x1 (Top,left)
buf+1 y1 , x1+1
: :
buf+(x2-x1) y1 , x2
buf+(x2-x1)+1 y1+1 , x1
: :
buf+(x2-x1+1)*(y2-y1+1)-1 y2 , x2 (Bottom,right)
[Example]
The following program backs up and restores the displayed characters
of upper 3 rows on the 14 inch screen.
#include <crt.h>
#include <stdlib.h>
[Name]
crt_puttextimg
[Syntax]
#include <crt.h>
int crt_puttextimg( unsigned int y1, unsigned int len x1,
unsigned int y2, unsigned int len x2,
unsigned long *buf, unsigned int op ) ;
[Arguments]
y1 Left,upper position of the area where characters are put.
x1 Left,lower position of the area where characters are put.
y2 Right,lower position of the area where characters are put.
x2 Right,upper position of the area where characters are put.
buf Area that characters data are stored.
op The way to put characters or attributes into VRAM.
[Return]
Returns zero when terminated normally, not zero when error, i.e.
specified coordinates is not correct, is occurred.
[Description]
Puts character codes on the screen, with their attribute.
#include <crt.h>
#include <stdio.h>
#include <stdlib.h>
[Name]
crt_setgraphpage
[Syntax]
#include <crt.h>
int crt_setgraphpage( int page ) ;
[Arguments]
page Graphic page number to use. (0, 1 or -1)
[Return]
Returns zero if successful. If any error (i.e. invalid page number
was specified), returns non-zero value.
[Description]
Select graphic page to use for graphic drawing.
The graphic system of FS30i has two pages for graphic drawing.
"_setactivepage" and "_setvisualpage" functions select graphic
page for drawing and displaying. "_setvideomode" function
initializes both two pages.
#include <crt.h>
#include <graph.h>
crt_closegr() ;
}
------------------------------------------------------------------------------
1.25 Select drawing method of 6x sized character. <Main>
------------------------------------------------------------------------------
[Name]
crt_set6chmode
[Syntax]
#include <crt.h>
int crt_set6chmode( int mode ) ;
[Arguments]
mode Drawing method of 6x sized character.
0: High speed mode
1: Complete mode
[Return]
0 Successful.
1 Invalid value (other than 0 and 1) is specified.
2 Ineffective in the current display mode.
[Description]
Selects drawing method of 6x sized character.
[Remarks]
This function is available only with the CNC screen display function
at the PC side on the FS300i system.
------------------------------------------------------------------------------
1.26 Select saving method of graphic contents. <Main>
------------------------------------------------------------------------------
[Name]
crt_setgsvmode
[Syntax]
#include <crt.h>
int crt_setgsvmode( unsigned int flag ) ;
[Arguments]
flag CRT_GSV_SAVE0 Save contents of page #0.
CRT_GSV_SAVE1 Save contents of page #1.
CRT_GSV_SAVE01 Save contents of page #0 and #1.
CRT_GSV_NOSAVE Not save any contents.
[Return]
0 Successful.
1 Invalid value of "flag".
2 Insufficient memory for graphic contents.
[Description]
Selects whether graphic contents are saved or not.
* NC -> C-EXE
(1) Restore contents of text screen.
(2) Execute equivalent process to "crt_opengr()".
(3) Execute equivalent process to "_setvideomode()".
(4) Restore graphic environment.
(5) Restore saved contents of graphic page.
After this process, the application program can continue to draw
any graphics without reconfigure graphic environment.
The following memory is required to save contents of graphic page.
Only graphic contents drawn in the base screen are saved. Graphic
contents drawn in the VGA window are not saved.
------------------------------------------------------------------------------
2.1 Open window. <Main>
------------------------------------------------------------------------------
[Name]
win_open
[Syntax]
#include <crt.h>
whandle win_open( winfo *spec, char *title, int flag ) ;
typedef int whandle ; /* window handle */
typedef struct _winfo {
unsigned int posl ; /* window line position */
unsigned int posc ; /* window column position */
unsigned int sizev ; /* window vertical size */
unsigned int sizeh ; /* window horizontal size */
} winfo ;
[Arguments]
spec window geometry(position& size) structure
title window title string
flag window attribute
[Return]
Returns window handle if successful. When failed, returns "-1" and
sets following error code to the global variable "errno".
[Description]
Creates new window on the screen.
+-----------------------------------------------+
| Full screen |<- Line 1
| |
| +--------------------------------+ |
| |#<-(posl,posc) ^ window| |
| | | | |
| | | | |
| | | | |
| | | sizev | |
| | | | |
| |<------------------+----------->| |
| | sizeh | | |
| | | | |
| | | | |
| | v | |
| +--------------------------------+ |
| ^ |
| Window frame |
| |<- Line N
+-----------------------------------------------+
^ ^
Column 1 Column M
N=30,M=80
While more than one windows are open, access to the screen areas
other than window areas is disabled. Generally, full screen should be
cleared before opening the first window, or the first window should be
full-screen window. When opening windows over the usual screen
display, display the base usual screen in the full-screen window.
Calling this function at the start of the application program as shown
in the following example will do this.
winfo mainwin ;
whandle win_main ;
mainwin.posl = 2 ;
mainwin.posc = 2 ;
mainwin.sizev = 23 ;
mainwin.sizeh = 78 ;
win_main = win_open( &mainwin, "Main Window", WIN_F_FULL ) ;
------------------------------------------------------------------------------
2.2 Close window. <Main>
------------------------------------------------------------------------------
[Name]
win_close
[Syntax]
#include <crt.h>
int win_close( void ) ;
[Arguments]
------
[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".
[Description]
Close active window.
When the last window is closed, screen display returns to the default
screen state where no windows are open. Otherwise, the window
underneath the closed window become active and whole screen is
redrawn.
------------------------------------------------------------------------------
2.3 Select window. <Main>
------------------------------------------------------------------------------
[Name]
win_select
[Syntax]
#include <crt.h>
int win_select( whandle handle ) ;
[Arguments]
handle window handle of the window to be selected
[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".
[Description]
Select one of the open windows on the screen for display window.
This function does not change the overlapping order of the window.
[Name]
win_activate
[Syntax]
#include <crt.h>
int win_activate( whandle handle ) ;
[Arguments]
handle window handle for the window to be activated
[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".
[Description]
Select one of the open windows on the screen for keyboard input.
[Name]
win_move
[Syntax]
#include <crt.h>
int win_move( int dy, int dx ) ;
[Arguments]
dy vertical displacement
dx horizontal displacement
[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".
[Description]
Move active window .
[Name]
win_size
[Syntax]
#include <crt.h>
int win_size( int dy, int dx ) ;
[Arguments]
dy vertical expansion/reduction value
dx horizontal expansion/reduction value
[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".
EW_DISP invalid size value specified
[Description]
Change active window size.
The size expansion value which would cause a part of the window to be
off the screen cannot be specified. Also the size reduction value
which would shrink the window less than the size of 1 line/1 column
cannot be specified.
[Name]
win_full
[Syntax]
#include <crt.h>
int win_full( void ) ;
[Arguments]
------
[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".
[Description]
Let the size of the active window be full screen size.
[Name]
win_window
[Syntax]
#include <crt.h>
int win_window( void ) ;
[Arguments]
------
[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".
[Description]
Active full screen window is shrunk to be a normal window.
[Name]
win_info
[Syntax]
#include <crt.h>
int win_info( whandle handle, winfo *spec ) ;
[Arguments]
handle window handle of the target window
spec pointer to the window geometry(size&position)
structure
[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".
[Description]
Get the position and size of the specified window. Position and size
is set to the corresponding member of the structure "spec".
------------------------------------------------------------------------------
2.10 Set color of window frame and title string. <Main>
------------------------------------------------------------------------------
[Name]
win_col
[Syntax]
#include <crt.h>
void win_col( int colf, int colt, int colh,
int colfa, int colta, int colha ) ;
[Arguments]
colf window frame color
colt window title color
colh window handle color
colfa active window frame color
colta active window title color
colfa active window handle color
[Return]
------
[Description]
Set color for window frame and window title string.
15 8 7 0
+------------------------+------------------------+
| 0 0 0 Ib Bb Gb Rb I | B G R r b 0 0 0 |
+------------------------+------------------------+
B: Blue r: Reverse video
G: Green b: Blink
R: Red
I: Low intensity
Bb:Background Blue
Gb:Background Green
Rb:Background Red
Ib:Background Low intensity
Colors and attributes set by this function are applied to the window
frames, titles or window handles which are displayed after this
function call. Colors or attributes of those already displayed when
this function is called is not affected. To change them, redraw the
window by calling functions to move, change size or hide/show the
window.
This function affects all windows.
------------------------------------------------------------------------------
2.11 Hide window. <Main>
------------------------------------------------------------------------------
[Name]
win_hide
[Syntax]
#include <crt.h>
int win_hide( whandle handle ) ;
[Arguments]
handle window handle for the window to be hidden
[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".
[Description]
Win_hide() hides specified window.
[Name]
win_show
[Syntax]
#include <crt.h>
int win_show( whandle handle ) ;
[Arguments]
handle window handle of the window to be hidden
[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".
[Description]
Windows hidden by win_hide() function become visible by this function.
[Name]
win_setttl
[Syntax]
#include <crt.h>
int win_setttl( whandle handle, char *title ) ;
[Arguments]
handle window handle of the window whose title string is to
be changed
title window title string
[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".
[Description]
Change title string for a window.
The length of the window title string should be less than 32 single
byte characters. (single byte alpha-numeric and Katakana characters,
symbols and double byte alpha-numeric, Hirakana, Kanji characters
and symbols can be used.)
Calling this function redraws whole screen.
------------------------------------------------------------------------------
2.14 Set window frame line character. <Main>
------------------------------------------------------------------------------
[Name]
win_setfrm
[Syntax]
#include <crt.h>
void win_setfrm( unsigned int *frame ) ;
[Arguments]
frame character code array which defines window frame line
style
[Return]
------
[Description]
Set user defined line style for window frame.
Set the FANUC character code for each window frame line to the
argument "frame" in the following order(horiz.-0, horiz.-1,
vert.-2, vert.-3, upper-left corner-4......).
[4]-----[0]-----[6]
| |
| |
[2] [3]
| |
| |
[5]-----[1]-----[7]
Window frame lines set by this function are applied to the windows
which are opened with WIN_F_FRM3 attribute after this function call.
Frame lines of those windows already opened with WIN_F_FRM3 attribute
are changed to the specified style when they are redrawn.
The line style set by this function is applied to all windows with
WIN_F_FRM3 attribute.
------------------------------------------------------------------------------
2.15 Get window display status. <Main>
------------------------------------------------------------------------------
[Name]
win_getstat
[Syntax]
#include <crt.h>
void win_getstat( struct winstat *stat ) ;
struct winstat {
whandle selected ; /* Window handle of the
currently selected window*/
whandle active ; /* Window handle of the
currently active window. */
unsigned int numwin ; /* Number of opened window. */
unsigned int winstack[MAX_WIN] ; /* Stacking order of
opened windows. */
} ;
[Arguments]
stat Windows status information.
[Return]
------
[Description]
Gets the current window display status.
The window handle the currently selected window and the currently
active window are stored in each "stat.selected" and "stat.active".
The number of the currently opend windows is stored in "stat.numwin".
The number in "stat.numwin" includes the windows hidden by "win_hide"
function. The stacking order of the all opened windows is stored in
"stat.winstack". The handles of all of the opened windows are stored
like this, the window handle of the top window is stored in
"winstack[0]", the next in "winstack[1]".
For example, three windows are opened now as below. This function
returns the following result.
+[1]-------------+
|Selected |
+[2]---| |
| | |
| | +[3]-------------+
| | |Active |
| +------| |
| | |
| | |
+-------------| |
+----------------+
stat.selected = 1
stat.active = 3
stat.numwin = 3
stat.winstack[0] = 3
stat.winstack[1] = 1
stat.winstack[2] = 2
(stat.winstack[3] and later are undefined.)
When "stat.numwin" = 0, that is, no window is opend, the contents of
"selected", "active" and "winstack" are undefined.
[Example]
The following program tests if the currently active window is selected
or not, then, if not, selects it.
#include <crt.h>
win_getstat( &stat ) ;
if ( ( numwin != 0 ) && ( stat.selected != stat.active ) )
win_select( stat.active ) ;
}
------------------------------------------------------------------------------
2.16 Redraw windows. <Main>
------------------------------------------------------------------------------
[Name]
win_redraw
[Syntax]
#include <crt.h>
void win_redraw( void ) ;
[Arguments]
------
[Return]
------
[Description]
Redraws all opening windows.
This function just redraw the opening and displayed window keeping
the current window status (open/close, displayed/hidden, overlapping
order of windows).
When the screen has been switched from/to NC side and PC side on "CNC
screen display function", use function to redraw windows.
3. User defined character library
3-1. scope
8 dots 16 dots
|<-------->| |<----------------->|
+----------+ - +-------------------+ -
| | ^ | | ^
| | | | | |
| | | | | |
| | | | | |
| | |16 dots | | |16 dots
| | | | | |
| | | | | |
| | | | | |
| | v | | v
+----------+ - +-------------------+ -
bit order-> #7 #0 #7 #0 #7 #0
+----------+ +-------------------+
| byte 1 | | byte 1 | byte 17 |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| v | | v | v |
| byte 16 | | byte 16 | byte 32 |
+----------+ +-------------------+
* Example
pattern ........
........
........
..###...
.#...#..
#.....#.
#.....#.
#.....#.
#######.
#.....#.
#.....#.
#.....#.
........
........
........
........
Binary 0x00,0x00,0x00,0x38,0x44,0x82,0x82,0x82,
notation 0xFE,0x82,0x82,0x82,0x00,0x00,0x00,0x00
- 2-byte character ("KAN" of Japanese KANJI character)
pattern ................
.......#...#....
.##..#########..
...#...#...#....
......#######...
.##...#..#..#...
...#..#######...
.........#......
...#..#######...
...#.....#......
...#.#########..
..#.....#.#.....
..#....#...#....
.##..##.....##..
................
................
Binary 0x00,0x01,0x67,0x11,0x03,0x62,0x13,0x00,
notation 0x13,0x10,0x17,0x20,0x21,0x66,0x00,0x00,
0x00,0x10,0xFC,0x10,0xF8,0x48,0xF8,0x40,
0xF8,0x40,0xFC,0xA0,0x10,0x0C,0x00,0x00
3-3. Character code
Character codes from 0x4100 to 0x41FF in FANUC code set are reserved for
user defined characters and automatically assigned to the user defined
character in the order of its registration. In case of 2-byte characters, two
consecutive codes are assigned to a 2-byte character, one for left half of
the dot pattern and the other for the right half, where the latter code being
the former plus one. The registered user defined characters can be accessed
and displayed on the screen by using FANUC code.
Also, JIS code can be assigned to the registered user defined characters.
Available codes are, from 0x20 to 0xDF for single byte characters and from
0x8140 to 0xEFDF shift JIS codes for 2-byte characters.
The above single byte character codes are those in single byte user
defined character mode that can be selected by the sequence "ESC (8" .
Assuming that the character "TORA" ,not included in the FANUC Kanji
character set, is to be displayed on the screen , make dot pattern
for the character, register it as an user defined character, and
assign the standard shift JIS code for the character "TORA" (0x8CD5)
to it. Thus, printing "TORA" by using printf() function as usual will
display the character "TORA" on the CNC screen.
(2) When registering new characters.
After making dot patterns for all user defined characters, describe them in
binary notation and store in an unsigned character string.
In the case of single byte character, switch the code set to the single byte
user character mode by the sequence "ESC (8" to specify the user character.
(Example) printf( "\033(8ABC\033(4" ) ;
Display user defined characters assigned to the code 0x41,
0x42 and 0x43. "ESC (4" is the sequence to select standard
mode.
In the case of 2-byte character, directly output the shift JIS code assigned
to the user defined character.
(Example) printf( "\x93\xC8\x96\xD8" ) ;
(This is Japanese string "TOCHI-GI".)
If the dot pattern of the character "TOCHI" is registered as an user
defined character and the code 0x93C8, which is the shift JIS code
for the standard JIS character "TOCHI",is assigned to the character,
the character "TOCHI" can be output to the screen as if it were
included in the FANUC Kanji character set.
printf( "\xEB\xA0" ) ;
When the code greater than 0xEB9F (0xEBA0 in this case), which is
vacant in shift JIS code area, is assigned, directly specify the code.
Function reference
~~~~~~~~~~~~~~~~~~
------------------------------------------------------------------------------
3.1 Register user character. <Main>
------------------------------------------------------------------------------
[Name]
crt_reguserchar
[Syntax]
#include <crt.h>
int crt_reguserchar( unsigned int number, unsigned char *table ) ;
[Arguments]
number the number of registered user defined characters in
bytes ( 1-- 256)
table pointer to the character pattern table
[Return]
0 normal completion
1 invalid number of user defined characters
[Description]
Register the character pattern of the user defined character.
[Name]
crt_mapuch
[Syntax]
#include <crt.h>
int crt_mapuch( unsigned int code, unsigned int ucode ) ;
[Arguments]
code code to be assigned
0x0020 through 0x00DF for single byte character
0x8140 through 0xEFFF for 2-byte character (limited
to those allowed in shift JIS code)
ucode FANUC code for the user defined character
(0x4100 through 0x41FF)
[Return]
0 normal completion
1 illegal character code assigned
[Description]
Assign single byte character code or JIS Kanji code for the user
defined character.
This function does not check the validity of the specified character
code. Care should be taken not to specify wrong character codes.
------------------------------------------------------------------------------
3.3 Get CG pattern. <Main>
------------------------------------------------------------------------------
[Name]
crt_getcgpttn
[Syntax]
#include <crt.h>
int crt_getcgpttn( unsigned int code, unsigned char *buf ) ;
[Arguments]
code the FANUC code for the character of which the
character pattern is to be get
buf buffer area where character pattern is stored
( 16 bytes )
[Return]
0 normal completion
1 reading the character pattern is not supported by this version
of Hardware
[Description]
Read the character pattern data stored in the character generator.
This function does not check the validity of the specified character
code. Care should be taken not to specify wrong character codes.
3-6. Sample application program
/* Character pattern */
unsigned char pattern[ UCH_NUM * CHAR_SIZE_14 ] = {
0x00,0x3F,0x02,0x02,0x02,0x3F,0x22,0x22, /* 0x4100 */
0x22,0x22,0x22,0x3F,0x02,0x02,0x02,0x7F,
0x00,0xFE,0x20,0x20,0x20,0xFE,0x22,0x22, /* 0x4101 */
0x22,0x22,0x22,0xFE,0x20,0x20,0x20,0xFF,
0x00,0x01,0x3C,0x24,0x24,0x25,0x25,0x25, /* 0x4102 */
0x25,0x25,0x25,0x25,0x3C,0x00,0x00,0x03,
0x00,0xFE,0x48,0x48,0x48,0xCE,0x02,0x02, /* 0x4103 */
0x02,0x02,0x02,0xCE,0x48,0x48,0x48,0xFF,
0x10,0x10,0x10,0x7E,0x12,0x12,0x12,0x22, /* 0x4104 */
0x22,0x24,0x24,0x14,0x08,0x14,0x22,0x41,
0x10,0x10,0x10,0xFE,0x10,0x10,0x10,0xFF, /* 0x4105 */
0x00,0x10,0x10,0xFE,0x10,0x10,0x10,0xFF,
0x00,0x3E,0x22,0x22,0x24,0x24,0x28,0x24, /* 0x4106 */
0x22,0x22,0x22,0x22,0x3C,0x20,0x20,0x20,
0x00,0xFF,0x02,0x02,0x02,0xFA,0x8A,0x8A, /* 0x4107 */
0x8A,0x8A,0x8A,0xFA,0x02,0x02,0x02,0x0E,
0x00,0x00,0x7F,0x00,0x1F,0x10,0x10,0x10, /* 0x4108 */
0x1F,0x02,0x04,0x1C,0x64,0x04,0x07,0x1C,
0x80,0x80,0xFF,0x00,0xFC,0x04,0x04,0x04, /* 0x4109 */
0xFC,0x80,0x44,0x48,0x30,0x10,0x8C,0x03,
} ;
* Overlapping on any arbitrary screen such as CNC, PMC and C-EXE screen.
+---------------------------------------------------+
| Full screen |
| |
| +--------------------------+ |
| |VGA window #0 | |
| | | |
| | +--------------------+ |
| |Also VGA win- |VGA window #1 | |
| |dow is over- | | |
| |lapped on the | | |
| |other window. |Both character and | |
| | |graphics are over- | |
| +--------------|lapped. | |
| | | |
| | | |
| +--------------------+ |
| |
| Displaying on the base screen is |
| not affected by any VGA window. |
+---------------------------------------------------+
Each two VGA windows have their own screen buffers of character and graphics
display It is possible to output to the base screen during displaying
VGA windows. Output operation to hidden area of the base screen displays
nothing to the real screen but writes to the screen buffer memory. When the
VGA window closed, all contents of the base screen, including on the hidden
area, are output automatically.
VGA window has the following restrictions.
* Color palettes are common with the base screen. So, if any color
palette is changed in the base screen or the VGA window, the
corresponding color palette of the other screen is changed.
* When the screen mode is changed, all VGA windows are closed auto-
matically.
* The VGA window cannot be used together with the CNC subscreen/help
screen. To use the VGA window, set parameter NSH(No.8654#0)=1 to
hide the subscreen/help screen.
Execute the following procedures to display VGA window in the window task.
(4) Call "vwin_close()" function to close the VGA window after required
displays.
The procedures to display VGA window in the main task is basically same as
in the window task. There are some differences as follows.
(2) Various settings about display are taken over between the base screen
and the VGA window as they are. Generally, it is necessary to re-
initialize the display environment after changing display between the
base screen and the VGA winodw. Call "_setvideomode()" function after
opening the VGA window, "crt_setmode()" and "_setvideomode()"
functions after returning the base window from the VGA window.
(3) The opened VGA window is still displayed as it is even if the base
screen is changed to another screen (CNC screen, etc.). It is im-
possible to control the VGA window on the CNC screen by the main task.
So, it is beter to disable screen switching during opening the VGA
window.
It is impossible to resize the opened VGA window. Close the VGA window by
"vwin_close()" function first, then open with new size specification again.
(Redrawing is required.)
Hide the VGA window by "vwin_hide()" function once, then call "vwin_show()"
function with the new position.
Hide the VGA window which you want display on the top by "vwin_hide()"
function once, then display it by "vwin_show()" with the same position again.
Function Reference
~~~~~~~~~~~~~~~~~~
------------------------------------------------------------------------------
4.1 Open VGA window. <Main,Win>
------------------------------------------------------------------------------
[Name]
vwin_open
[Syntax]
#include <crt.h>
int vwin_open( unsigned int widx,
unsigned int posl, unsigned int posc,
unsigned int sizev, unsigned int sizeh ) ;
[Arguments]
widx VGA window index. (=0,1)
posl Line number of the upper left corner of VGA window.
(the top line in the screen = 0)
posc Column position of the upper left corner of VGA window.
(the left-end column in the screen = 0)
sizev Line size of VGA window. (=1 - LMAX)
sizeh Column size of VGA window. (=1 - CMAX)
LMAX = 30
CMAX = 80
[Return]
0 Successful.
Non-0 Error. (one of the following cases)
- Incorrect window index (widx).
- Specified window has been already opened.
- Incorrect position or size of window.
- The other software already uses the VGA window.
[Description]
Makes a VGA window and displays it on the screen.
A VGA window with the specified size is opened and displayed on the
screen at the specified position. It is allowed to specify position
that a part of the window is put out of the screen.
The window created by this function is selected and is put on the
other window which is already displayed.
After successful execution of this function, the following printing
and drawing are output to the window opened by this function until
closing this window or the other window is selected.
------------------------------------------------------------------------------
4.2 Close VGA window. <Main,Win>
------------------------------------------------------------------------------
[Name]
vwin_close
[Syntax]
#include <crt.h>
int vwin_close( unsigned int widx ) ;
[Arguments]
widx VGA window index. (=0,1)
[Return]
0 Successful.
Non-0 Error. (one of the following cases)
- The window specified by "widx" is not opened.
[Description]
Closes the opened VGA window.
When all VGA windows are closed in the main task, the base screen
(ordinary screen) is selected.
------------------------------------------------------------------------------
4.3 Select VGA window. <Main,Win>
------------------------------------------------------------------------------
[Name]
vwin_select
[Syntax]
#include <crt.h>
int vwin_select( unsigned int widx ) ;
[Arguments]
widx VGA window index. (=0,1)
[Return]
0 Successful.
Non-0 Error. (one of the following cases)
- The window specified by "widx" is not opened.
[Description]
Selects the specified VGA window as the target screen of character
and graphics output.
[Name]
vwin_show
[Syntax]
#include <crt.h>
int vwin_show( unsigned int widx,
unsigned int posl, unsigned int posc ) ;
[Arguments]
widx VGA window index. (=0,1)
posl Line number of the upper left corner of VGA window.
(the top line in the screen = 0)
posc Column position of the upper left corner of VGA window.
(the left-end column in the screen = 0)
[Return]
0 Successful.
Non-0 Error. (one of the following cases)
- The window specified by "widx" is not opened.
- The window specified by "widx" is not hidden window.
[Description]
Redisplays the invisible VGA window.
[Name]
vwin_hide
[Syntax]
#include <crt.h>
int vwin_hide( unsigned int widx ) ;
[Arguments]
widx VGA window index. (=0,1)
[Return]
0 Successful.
Non-0 Error. (one of the following cases)
- The window specified by "widx" is not opened.
[Description]
Hides the specified VGA window.
This function makes the opened VGA window invisible with keeping the
window's status. It is possible to output characters and graphics to
the invisible window.
[Name]
vwin_info
[Syntax]
#include <crt.h>
int vwin_info( unsigned int widx, struct vwinfo *buf ) ;
struct vwinfo {
unsigned int stat ; /* status */
unsigned int posl ; /* line position */
unsigned int posc ; /* column position */
unsigned int sizev ; /* vertical size */
unsigned int sizeh ; /* horizontal size */
} ;
[Arguments]
widx VGA window index. (=0,1)
buf Window iformation buffer.
[Return]
0 Successful.
Non-0 Error. (one of the following cases)
- Incorrect window index (widx).
[Description]
Gets the status information of the specified VGA window.
The position, size and status of the specified window are stored into
"buf".
The meanings of each bit of the status flag "buf.stat" are as follows.
bit0 VW_OPEN = 0 Not opened.
= 1 Opened.
bit1 VW_HIDDEN = 0 Visible.
= 1 Invisible.
(VW_HIDDEN is effective when VW_OPEN=1.)
bit2 - bit15 Undefined.
3.7 File Operation Library
==========================
The application program can access a memory card which is inserted in the
card slot equipped on the LCD/MDI panel of FS30i as a disk device.
(2) Mount the memory card as a disk device by the application program.
(Call "aux_file_mount" function.)
(3) Open files using "fopen", "fcreate" function, etc. with drive name
"B:".
PCMCIA or JEIDA compatible 256KB, 512KB, 1MB, 2MB, 4MB S-RAM card.
* The C application program can't access the memory card while the other
software (CNC software, etc.) is accessing it.
* The C application program may fail to access the memory card just after
insertion the memory card (for a few minutes). ("aux_file_mount" function
returns "EAUTHREJ".) The CNC program causes this problem because it always
poring the card slot to detect card insertion. In this case, the appli-
cation program must retry to access.
Lists of Functions
~~~~~~~~~~~~~~~~~~
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
1. aux_file_format Format specified drive
2. aux_file_mount Mount memory card.
3. aux_file_unmount Unmount memory card.
4. aux_file_memcinfo Get memory card information.
--------------------------------------------------------------------------
Function Reference
~~~~~~~~~~~~~~~~~~
------------------------------------------------------------------------------
1. Format specified drive <Main>
------------------------------------------------------------------------------
[Name]
aux_file_format
[Syntax]
#include <auxfile.h>
int aux_file_format( unsigned char drive ) ;
[Arguments]
drive Drive name ( ='A' )
[Return]
0 normal completion
9 invalid drive name
[Description]
This function formats the drive specified by the argument.
[Name]
aux_file_mount
[Syntax]
#include <auxfile.h>
int aux_file_mount( unsigned char drive ) ;
[Arguments]
drive Drive name. ( ='B' )
[Return]
Returns 0 if successfully mounted the memory card.
If failed, returns non-0, and store one of the following values in
the global variable "errno".
Symbol Meaning
---------------+-----------------------------------------------------
ENOTMOUNT Failed to mount.
ENOTINSERT No memory card inserted.
EBATVOLDEC Battery voltage is low.
ENOTSRAM Not supported card. (Not S-RAM card.)
EDRIVENAME Invalid drive name.
EAUTHREJ The other software already uses the memory card slot.
[Description]
Mounts the memory card.
#include <stdio.h>
#include <auxfile.h>
[Name]
aux_file_unmount
[Syntax]
#include <auxfile.h>
int aux_file_unmount( unsigned char drive ) ;
[Arguments]
drive Drive name. ( ='B' )
[Return]
Returns 0 if successfully unmounted the memory card.
If failed, returns non-0, and store one of the following values in
the global variable "errno".
Symbol Meaning
---------------+-----------------------------------------------------
ENOTMOUNT Failed to unmount.
ENOTINSERT No memory card inserted.
EBATVOLDEC Battery voltage is low.
ENOTSRAM Not supported card. (Not S-RAM card.)
EDRIVENAME Invalid drive name.
EAUTHREJ The other software already uses the memory card slot.
[Description]
Unmounts the memory card.
[Example]
See example of "Mount memory card (aux_file_mount)".
------------------------------------------------------------------------------
4. Get memory card information. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
aux_file_memcinfo
[Syntax]
#include <auxfile.h>
int aux_file_memcinfo( unsigned int *stat ) ;
[Arguments]
stat Buffer in which memory card information is stored.
[Return]
Returns 0 if successfully got the memory card information.
If failed, returns non-0.
[Description]
Reads the status of the memory card.
[Example]
See example of "Mount memory card (aux_file_mount)".
3.8 Serial Library
==================
Library outline
~~~~~~~~~~~~~
1. Outline
[1] Protocol
start-stop synchronization transmission ( 2 channels max.)
+------------------------------------------------+
| |
| application |-------+
| | |
+------------------------------------------------+ |
| | |
+----------------+ +----------------+ |
| | -+ | | -+ |
| Tx buffer | | | Rx buffer | | Status
| | | | | | check
+----------------+ | +----------------+ | |
+----------------+ +----------------+ |
| | |
+------------------------------------------------+ |
| | |
| Serial device |<------+
| |
+------------------------------------------------+
Application program sends data to the serial device via transmit buffer
(Tx buffer) and receives data from the serial device through receive buffer
(Rx buffer). Status information is directly read from the serial device.
[3] Authorization to access communication channel
Two flow control methods are supported: one uses hardware signals (CS,ER)
for handshaking and the other uses DC code for it ( referred to as "hardware
flow ctrl" and " DC code flow ctrl" respectively). Following parameters can
be selected.
(Note) When "none" is selected for hardware flow ctrl, RS signal becomes
always ON.
When "DC code flow ctrl" is selected, data transmission is controlled by the
DC codes as follows.
(1) Transmission handshake
DC code is used to request the source device to stop or restart sending data
according to the state of receiving buffer.
Only data transmission from application program to external device can take
place in this mode. Application program cannot use library functions for
receiving data. Data received from external device are ignored except DC
codes.
Only data transmission from external device to application program can take
place in this mode. Application program cannot use library functions for
sending data. All received data from external devices are passed to
application program.
DC codes included in the receiving data from external device are interpreted
as flow control characters and they are not passed to the application program.
Because external device would not send DC codes to the application program
for flow control purposes in this mode, all receiving data including DC codes
are passed to the application program.
In this mode, care should be taken for the relationship between flow control
method and transmitted data. When bi-directional "DC code flow ctrl" is
employed, DC codes in transmitted data, if included as data, cannot be
discriminated from flow control DC characters. And these data not only are
blocked to pass to the application program but cause flow control failure.
Moreover, the DC code to announce "send stop/send restart" cannot be sent to
the destination, if "send data" is inhibited by the hardware signal. For these
reasons, only text data should be transmitted when "DC code flow ctrl" is
employed. If hardware signal handshake is employed, there is no restriction
in the code of transmitted data.
2. Interface
[1] Connection
Only difference between "hardware flow ctrl" and "no hardware flow ctrl" is
that signals CS and DR are deemed always ON if "no hardware flow ctrl" is
selected.
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
1. rs_open Initialize communication channel
2. rs_close Close communication channel
3. rs_putc Put one byte data into transmit buffer
4. rs_getc Get one byte data from receive buffer
5. rs_write Put block of data into transmit buffer
6. rs_read Get block of data from receive buffer
7. rs_buffer Test or clear transmit/receive buffer
8. rs_status Get status of communication buffer and
interface
9. rs_wait Wait for communication interface event
--------------------------------------------------------------------------
(Note 2) The serial library functions do not check the signal, DR. It should
be checked by application program if necessary.
Function Reference
~~~~~~~~~~~~~~~~~~
------------------------------------------------------------------------------
1. Initialize communication channel <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
rs_open
[Syntax]
#include <bios.h>
int rs_open( int channel, ser_t *param, char *mode ) ;
struct RS_PACKET {
unsigned baud ; /* baud rate */
unsigned stop_bit ; /* stop bit length */
unsigned parity ; /* parity check */
unsigned data_bit ; /* character length */
unsigned hardflow ; /* hardware flow ctrl */
unsigned dc_enable ; /* DC code flow ctrl */
unsigned dc_put ; /* send DC code */
unsigned dc1_code ; /* DC1 code */
unsigned dc2_code ; /* DC2 code */
unsigned dc3_code ; /* DC3 code */
unsigned dc4_code ; /* DC4 code */
} ;
typedef struct RS_PACKET ser_t ;
[Argument]
channel channel number ( = 1, 2 )
param communication parameter
mode communication mode
[Return]
Returns zero if successful. If any error, returns non-zero value.
[Description]
Specified communication channel is initialized with specified
condition and opened for data transmission.
Specify channel number, 1 or 2, by the argument "channel".
Specify communication conditions in the structure "param".
[Name]
rs_close
[Syntax]
#include <bios.h>
int rs_close( int channel ) ;
[Argument]
channel channel number ( = 1, 2 )
[Return]
Returns zero if successful. If any error, returns non-zero value.
[Description]
Stops using specified communication channel.
If "1" is specified for param->dc_put of rs_open() function, DC3 code
(for receive mode) or DC4 code (for send mode) is sent via
communication channel.
------------------------------------------------------------------------------
3. Put one byte data into transmit buffer <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
rs_putc
[Syntax]
#include <bios.h>
int rs_putc( int c, int channel ) ;
[Argument]
c data to be sent
channel channel number ( = 1, 2 )
[Return]
Returns "1" if successful. Returns zero if transmit buffer is full and
has no room to accept new data. Returns "-1" if any error. The error
comes from transmit buffer and has nothing to do with the state of
communication interface.
[Description]
Puts one byte data into the transmit buffer of the specified
communication channel.
This function outputs data to the transmit buffer. To know if the data
is actually transmitted , read the status of the transmit buffer by
rs_buffer() function and check the vacancy of the buffer.
------------------------------------------------------------------------------
4. Get one byte data from receive buffer <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
rs_getc
[Syntax]
#include <bios.h>
int rs_getc( int channel ) ;
[Argument]
channel channel number ( = 1, 2 )
[Return]
Returns a data read from receive buffer if successful. Returns "-1" if
any error occurs or if there is no data in the buffer. The error comes
from receive buffer and has nothing to do with the state of
communication interface.
[Description]
Gets one byte data from the receive buffer of the specified
communication channel.
------------------------------------------------------------------------------
5. Put block of data into transmit buffer <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
rs_write
[Syntax]
#include <bios.h>
int rs_write ( char *buffer, int size, int channel ) ;
[Argument]
buffer output data storage area
size output data size
channel channel number ( = 1, 2 )
[Return]
Returns the size of the data output to the transmit buffer if
successful. If free space of the transmit buffer is smaller than the
specified data size, returned value will be smaller than the specified
data size. Returns "-1" if any error. The error comes from the
transmit buffer and has nothing to do with the state of communication
interface.
[Description]
Gets specified bytes of data from the specified buffer area and puts
them into the transmit buffer of the specified channel
This function outputs data to the transmit buffer. To know if the data
is actually transmitted, read the status of the transmit buffer by
rs_buffer() function and check the vacancy of the buffer.
------------------------------------------------------------------------------
6. Get block of data from receive buffer <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
rs_read
[Syntax]
#include <bios.h>
int rs_read ( char *buffer, int size, int channel ) ;
[Argument]
buffer input data storage area
size input data size
channel channel number ( = 1, 2 )
[Return]
Returns the number of data bytes read from the receive buffer if
successful. If size of the data in the receive buffer is less than
specified size, return value will be smaller than specified size.
Returns "-1" if any error. This error comes from receive buffer and
has nothing to do with the state of communication interface.
[Description]
Gets specified bytes of data from the receive buffer of the specified
channel and puts them into the specified buffer area.
------------------------------------------------------------------------------
7. Test or clear transmit/receive buffer <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
rs_buffer
[Syntax]
#include <bios.h>
int rs_buffer( int channel, int cmnd ) ;
[Argument]
channel Channel number ( = 1, 2 )
cmnd buffer command
[Return]
If successful;
RS_GET_BUF_R, RS_GET_BUF_W commands return buffer size,
RS_CHK_BUF_R, RS_CHK_BUF_W commands return data size in the buffer
RS_CLR_BUF_R, RS_CLR_BUF_W commands return zero.
Returns "-1", if any error.
[Description]
Tests or clears the specified buffer of the specified channel.
cmnd function
---------------+-----------------------------------
RS_GET_BUF_R return receive buffer size
RS_GET_BUF_W return transmit buffer size
RS_CHK_BUF_R return data size in receive buffer
RS_CHK_BUF_W return data size in transmit buffer
RS_CLR_BUF_R clear receive buffer
RS_CLR_BUF_W clear transmit buffer
------------------------------------------------------------------------------
8. Get status of communication buffer and interface <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
rs_status
[Syntax]
#include <bios.h>
int rs_status( int channel ) ;
[Argument]
channel channel number ( = 1, 2 )
[Return]
Returns status of the communication interface and communication
buffers.
0x0080 DR ON (LSI)
0x0040 ( reserved ) (LSI)
0x0020 Framing error (LSI)
0x0010 Overrun error (LSI)
0x0008 Parity error (LSI)
0x0004 ( reserved ) (LSI)
0x0002 ( reserved ) (LSI)
0x0001 ( reserved ) (LSI)
[Description]
Gets status information of the communication interface and
communication buffers of the specified channel.
------------------------------------------------------------------------------
9. Wait for communication interface event <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
rs_wait
[Syntax]
#include <bios.h>
#include <oscall.h>
int rs_wait( int channel, int param, int mode,
unsigned long time_out ) ;
[Arguments]
channel channel number ( = 1, 2 )
param character code or number of characters
mode operation mode
time_out maximum time to wait
[Return]
Returns zero if specified condition is satisfied.
Returns "EC_TIMOUT" if time limit set by time_out has elapsed..
When mode = rtx_size, this function returns "rtx_size_ok" if the
number of data bytes in the receive buffer is greater than or equal to
the specified value. When mode = trx_size, this function returns
"trx_size_ok" if the number of data bytes in the transmit buffer is
less than or equal to the specified value. Returns the value other
than described above if any error.
T[Description]
Waits for the specified communication channel to become given state.
mode param
---------------+------------------------------------------
rtx_size number of data characters in the receive
buffer
trx_size number of data characters in the transmit
buffer
rtx_code character code
This function is used for the case to know the arrival of the
data packet which ends with specific code.
Library outline
~~~~~~~~~~~~~~~
1. Time management
The time management functions can suspend execution of tasks for specified
period of time or can make tasks wait for events with limited wait time option
which avoids tasks to become dead-locked. The timer which can be used by the
application program is a local timer dedicated for the task. Time unit of the
timer is "Tick"(1 Tick = 8 msec).
name function
---------------+---------------------------------------------------
os_show_tim read timer
os_set_tim set timer
os_sync_tim suspend execution of task until specified time
of timer
os_wait_tim suspend execution of task for specified time period
Name Function
---------------+--------------------------------------
os_make_sem create semaphore
os_delt_sem delete semaphore
os_wait_sem wait until semaphore is signaled
os_sign_sem signal semaphore
Signaling semaphore
~~~~~~~~~~~~~~~~~~~
+-----------+
Signal | resources | Task Queue Wait
<====== | TASK-A | <=== (TASK-D)==(TASK-E)==
| TASK-B |
| TASK-C |
+-----------+
semaphore
TASK-A TASK-B TASK-C TASK-D TASK-E counter value
| | | | | 3
Wait SEM | | | | 2
X Wait SEM | | | 1
X X Wait SEM | | 0
X X X Wait SEM | -1
X X X (Wait) Wait SEM -2
X X X (Wait)
Signal SEM X X X -1
| Signal SEM X X X 0
| | Signal SEM X X 1
| | | Signal SEM X 2
| | | | Signal SEM 3
| | | | |
V V V V V
Assume that the TASK-A writes a data into the buffer and the TASK-B
reads the data from the buffer. Writing a data into the buffer where a
data is remaining unread, or reading the buffer when no data is
written, is not allowed.
+-------+
+------------> | SEM C | <--------------+
| +-------+ |
| +-------+ |
| +------> | SEM D | <-------+ |
| | +-------+ | |
Wait Signal Wait Signal
| | buffer(shared memory) | |
+--------+ +--------+ Read +--------+
| TASK A | | | =====> | TASK B |
+--------+ |--------| +--------+
| | |
| Write |--------|
+=====> | |
+--------+
Execution of tasks can be suspended until the state of an event group matches
a specific data pattern.
MSB LSB
31 0
+---------------+---------------+---------------+---------------+
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+---------------+---------------+---------------+---------------+
| |
| +-> flag 1
| :
| :
| :
+---------------------------------------------------------------> flag 32
Event group
~~~~~~~~~~~
A signal can wake all of the suspended tasks of which the triggering condition
is satisfied.
+--------------------------+
+----------------> | event flag |
| +--------------------------+
signal | waiting for event |
| +---------------+---------------+
| | | |
+---------+ +---------+ +---------+ +---------+
| TASK A | | TASK B | | TASK C | | TASK D |
+---------+ +---------+ +---------+ +---------+
Following functions are used for event flag management.
Name Function
---------------+----------------------------------------------
os_make_flg create event flag
os_delt_flg delete event flag
os_sign_flg signal event flag ( modal type)
os_puls_flg signal event flag ( pulse type)
os_wait_flg wait for being signaled
os_clar_flg clear event flag
(a) OR wait
The execution of the calling task is suspended until all three flags
1,2 and 3 are signaled. Flags, set ON in the event flag image before
the function is called, are not accounted as flags to be waited.
For example, if flags 1 and 2 are ON in the event flag image, the task
waits for only flag 3 to be signaled.
If three flags 1,2 and 3 are all ON in the event flag image before the
function is called, the calling task is not suspended.
operation
~~~~~~~~~
wait message = ~image & wait message
if( wait message != 0 )
Wait ==> wait until "wait massage" is satisfied
For example, to signal the event flag 1,2 and 3 to become ON, specify
0x00000007 for the parameter of os_sign_flg(). (This parameter is referred to
as "signal message".)
The suspended tasks which are waiting for the flags, that are specified by
this function call, to be signaled are waked.
os_puls_flg() does not memorize the signaled flags in the event flag
image. Accordingly, subsequent 0s_wait_flg() function call specifying
the signaled flags as "wait message" will suspend the calling task
again.
operation
~~~~~~~~~
if( signal message & wait message != 0 )
Ready ===> waked
operation
~~~~~~~~~
wait message = ~signal message & wait message
if( wait message == 0 )
Ready ===> waked
operation
~~~~~~~~~
flag image = ~clear message & flag image
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
1. os_show_tim read timer
2. os_set_tim set timer
3. os_sync_tim suspend execution of task until specified time
of timer
4. os_wait_tim suspend execution of task for specified time
period
5. os_make_flg create event flag
6. os_delt_flg delete event flag
7. os_sign_flg signal event flag
8. os_wait_flg wait for being signaled
9. os_clar_flg clear event flag
10. os_puls_flg signal event flag (pulse type)
11. os_make_sem create semaphore
12. os_delt_sem delete semaphore
13. os_sign_sem signal semaphore
14. os_wait_sem wait until semaphore is signaled
15. os_strt_wtsk Start window task
--------------------------------------------------------------------------
Function Reference
~~~~~~~~~~~~~~~~~~
------------------------------------------------------------------------------
1. Read timer <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
os_show_tim
[Syntax]
#include <oscall.h>
void os_show_tim( unsigned long *current_timer_value ) ;
[Argument]
current_timer_value value read from the timer
[Return]
------
[Description]
Reads current value of the timer.
The time value read by this function is that of local timer dedicated
for the calling task.
The contents of the timer read by this function does not always agree
with the actual passage of time. To read the time of day, use clock()
function which is more accurate.
------------------------------------------------------------------------------
2. Set timer <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
os_set_tim
[Syntax]
#include <oscall.h>
void os_set_tim( unsigned long new_timer_value,
unsigned long *old_timer_value ) ;
[Argument]
new_timer_value new timer value
old_timer_value old timer value
[Return]
------
[Description]
The timer set by this function is the local timer dedicated for the
calling task.
The contents of the timer read by this function does not always agree
with the actual passage of time. To read the time of day, use clock()
function which is more accurate.
------------------------------------------------------------------------------
3. Suspend execution of task until specified time of timer <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
os_sync_tim
[Syntax]
#include <oscall.h>
unsigned short os_sync_tim( unsigned long wakeup_time ) ;
[Argument]
wakeup_time time to wake up
[Return]
0 successful completion
EC_TIMOUT Time Out
[Description]
This function suspends the execution of the calling task until
timer reaches the specified time value.
This function cannot suspend the execution of tasks other than the
calling task.
This function does not return error value, zero. When the timer
reaches the specified time, returns error value, EC_TIMOUT.
[Name]
os_wait_tim
[Syntax]
#include <oscall.h>
unsigned short os_wait_tim( unsigned long timeout_value ) ;
[Argument]
timeout_value time period to wait
[Return]
0 successful completion
EC_TIMOUT Time Out
[Description]
Suspends execution of the calling task for the specified time period.
This function cannot suspend the execution of tasks other than the
calling task.
This function does not return error value, zero. When specified time
period is elapsed, returns error value, EC_TIMOUT.
[Name]
os_make_flg
[Syntax]
#include <oscall.h>
unsigned short os_make_flg( unsigned char event_flag_id ) ;
[Argument]
event_flag_id event flag ID
[Return]
0 successful completion
EC_FLGID Event-flag ID error
EC_EXSTFLG Already existing event-flag
[Description]
Creates event group with specified event flag ID .
[Name]
os_delt_flg
[Syntax]
#include <oscall.h>
unsigned short os_delt_flg( unsigned char event_flag_id ) ;
[Argument]
event_flag_id event flag ID
[Return]
0 successful completion
EC_FLGID Event-flag ID error
EC_NXSTFLG Non-existent event-flag
[Description]
This function deletes the event group specified by "event_flag_id".
[Name]
os_sign_flg
[Syntax]
#include <oscall.h>
unsigned short os_sign_flg( unsigned char event_flag_id,
unsigned long flag_on_message ) ;
[Argument]
event_flag_id event flag ID
flag_on_message signal message
[Return]
0 successful completion
EC_FLGID Event-flag ID error
EC_NXSTFLG Non-existent event-flag
[Description]
Signals event flags specified by "event_flag_id" and signal message.
[Name]
os_wait_flg
[Syntax]
#include <oscall.h>
unsigned short os_wait_flg( unsigned char event_flag_id,
unsigned long wait_message,
unsigned short and_or, long wait_limit,
unsigned long *return_message ) ;
[Argument]
event_flag_id event flag ID
wait_message wait message
and_or AND -- 0, OR -- 1
wait_limit Set 0.
return_message
[Return]
0 successful completion
EC_FLGID Event-flag ID error
EC_NXSTFLG Non-existent event-flag
EC_DELFLG Event-flag was deleted
EC_TIMOUT Time out
[Description]
Waits for specified signals to be signaled.
[Name]
os_clar_flg
[Syntax]
#include <oscall.h>
unsigned short os_clar_flg( unsigned char event_flag_id,
unsigned long clear_message ) ;
[Argument]
event_flag_id event flag ID
clear_message clear message
[Return]
0 successful completion
EC_FLGID Event-flag ID error
EC_NXSTFLG Non-existent event-flag
[Description]
Clears the event flag image.
This function clears the flags in the event flag image which are
specified by the clear_message..
------------------------------------------------------------------------------
10. Signal event flag (pulse type) <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
os_puls_flg
[Syntax]
#include <oscall.h>
unsigned short os_puls_flg( unsigned char event_flag_id,
unsigned long puls_message ) ;
[Argument]
event_flag_id event flag ID
puls_message signal message
[Return]
0 successful completion
EC_FLGID Event-flag ID error
EC_NXSTFLG Non-existent event-flag
[Description]
Signals the event flags specified by the puls_message argument.
[Name]
os_make_sem
[Syntax]
#include <oscall.h>
unsigned short os_make_sem( unsigned char semaphore_id,
char initial_value ) ;
[Argument]
semaphore_id semaphore ID
initial_value initial value of the semaphore counter
[Return]
0 successful completion
EC_SEMID Semaphore ID error
EC_EXSTSEM Already existing semaphore
[Description]
Creates a counter type semaphore.
[Name]
os_delt_sem
[Syntax]
#include <oscall.h>
unsigned short os_delt_sem( unsigned char semaphore_id ) ;
[Argument]
semaphore_id semaphore ID
[Return]
0 successful completion
EC_SEMID Semaphore ID error
EC_NXSTSEM Non-existent semaphore
[Description]
Deletes semaphore.
[Name]
os_sign_sem
[Syntax]
#include <oscall.h>
unsigned short os_sign_sem( unsigned char semaphore_id ) ;
[Argument]
semaphore_id semaphore ID
[Return]
0 successful completion
EC_SEMID Semaphore ID error
EC_NXSTSEM Non-existent semaphore
EC_SEMOVF Semaphore overflow
[Description]
Signals the semaphore specified by the "semaphore_id" argument.
This function increments the semaphore counter, and runs the task
at the top of the semaphore queue if the value of the semaphore
counter becomes less than or equal to zero.
------------------------------------------------------------------------------
14. Wait until semaphore is signaled <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
os_wait_sem
[Syntax]
#include <oscall.h>
unsigned short os_wait_sem( unsigned char semaphore_id,
long wait_limit ) ;
[Argument]
semaphore_id semaphore ID
wait_limit Set 0.
[Return]
0 successful completion
EC_SEMID Semaphore ID error
EC_NXSTSEM Non-existent semaphore
EC_DELSEM Semaphore was deleted
EC_TIMOUT Time out
EC_SEMUDF Semaphore underflow
[Description]
Waits until semaphore is signaled.
[Name]
os_strt_wtsk
[Syntax]
#include <oscall.h>
unsigned short os_strt_wtsk( unsigned int wghs ) ;
[Argument]
wghs Global heap size of the window task in kilo-byte.
[Return]
0 Successful.
0x010C No window task exists.
0x011B Not enough memory to start the window task.
[Description]
Starts the window task.
This function starts the window task. Until calling this function,
the window task keeps "start pending" status and is not executed.
Specify the global heap size for the window task in "wghs".
Generally, 100KB is enough size.
[Example]
The following program which is called in the main task starts the
window task.
#include <oscall.h>
#include <stdio.h>
void example( void )
{
unsigned short ret ;
ret = os_strt_wtsk( 100 ) ;
if ( ret )
printf( "ERROR, can't start Window TASK.\n" ) ;
else
printf( "Window TASK has started.\n" ) ;
}
3.10 FCA Library
================
Library outline
~~~~~~~~~~~~~~~
1. Outline
[1] Function
Available functions are listed below. Note that actually available functions
are limited by the function of the connected peripheral device. For more
details refer to the operating manuals for each FCA devices.
[2] Protocol
+---------------------------------------+
| |
| Application |
| |
+-------------------+-------------------+
|
+-------------------+-------------------+
| |
| FCA Library |
| |
+-------------------+-------------------+
|
+-------------------+-------------------+
| |
| Serial Library |
| |
+-------------------+-------------------+
|
+-------------------+-------------------+
| |
| Serial Device |
| |
+---------------------------------------+
When the FCA Library Function, fca_setparam(), is called, the serial port is
switched to the FCA mode. In this mode, it is recommended not to use standard
Serial Library Functions, rs_xxx. Though these functions can be used in the
FCA mode, detailed understandings of the FCA devices are required to do that.
When a serial port is switched to the FCA mode, the port becomes being under
control of the application program and the signal "ER" becomes "ON". In this
state, communication cable should not be disconnected or connected to protect
devices from hardware damage.
By calling the FCA Library Function, fca_bye(), the serial port is returned
to the idle state. That is, the port is released from the control of the
application program and the signal "ER" becomes "OFF".
+----------------+ +------------------+
| | | +--------------+ |
| | | | | |
| -----fca_setparam()------> | |
| | | | FCA mode | |
| <-------fca_bye()--------- | |
| | | | | |
| Idle state | | +--------------+ |
| | | |
| --------rs_open()--------> |
| | | |
| <-------rs_close()-------- |
| | | General mode |
| | | |
+----------------+ +------------------+
While in FCA mode, other FCA Library Functions, fca_xxx(), can be called. If
they are called prior to the fca_setparam() function, the operation of those
functions are not guaranteed.
One task can put multiple serial ports into FCA mode, but the port actually
used is the one which is specified by the last fca_setparam() function called.
Though "Protocol B" is the standard protocol, the FCA Library Function does
not set the protocol automatically, because protocols other than that can also
be set on the FCA devices. Select appropriate protocol according to the
setting of the connected device. As to the setting method of the protocol,
refer to the General mode function, rs_open().
Transmit and receive mode is selected and data can be sent or received at
any time when required.
List of Functions
~~~~~~~~~~~~~~~~~
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
1. fca_setparam Initialize communication line.
2. fca_bye Close communication line.
3. fca_open Open a binary file on FCA device.
4. fca_close Close a binary file.
5. fca_read Read binary data from the file.
6. fca_write Write binary data to the file.
7. fca_fopen Open a text file on FCA device.
8. fca_fclose Close a text device.
9. fca_getc Read a character from the text file.
10. fca_putc Write a character to the text file.
11. fca_delete Delete a file on FCA device.
12. fca_rename Change name of a file on FCA device.
13. fca_readdir Read directory information of FCA device.
14. fca_status Read status information of FCA device.
15. fca_remains Read free space size of a floppy disk.
--------------------------------------------------------------------------
(Note 1) Even when an error occurs in FCA device, FCA functions do not return
error status.
Function Reference
~~~~~~~~~~~~~~~~~~
------------------------------------------------------------------------------
1. Initialize communication line. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fca_setparam
[Syntax]
#include <bios.h>
int fca_setparam( int channel, ser_t *param ) ;
struct RS_PACKET {
unsigned baud ; /* baud rate */
unsigned stop_bit ; /* stop bit length */
unsigned parity ; /* parity check */
unsigned data_bit ; /* character length */
unsigned hardflow ; /* hardware flow ctrl */
unsigned dc_enable ; /* DC code flow ctrl */
unsigned dc_put ; /* send DC code */
unsigned dc1_code ; /* DC1 code */
unsigned dc2_code ; /* DC2 code */
unsigned dc3_code ; /* DC3 code */
unsigned dc4_code ; /* DC4 code */
} ;
typedef struct RS_PACKET ser_t ;
[Argument]
channel Channel number. ( = 1 or 2 )
param Communication parameter.
[Return]
Returns zero if successful. If any error, returns non-zero value.
[Description]
Specified communication channel is initialized with specified
condition and opened for data transmission.
When this function is called, the serial port is switched to the FCA
mode. In this mode, it is recommended not to use standard Serial
Library functions, rs_xxx. Though these functions can be used in the
FCA mode, detailed understandings of the FCA devices are required to
do that. When a serial port is switched to the FCA mode, the port
becomes being under control of the application program and the signal
"ER" becomes "ON". In this state, communication cable should not be
disconnected or connected to protect devices from hardware damage.
While in FCA mode, other FCA Library Functions, fca_xxx(), can be
called. If they are called prior to the fca_setparam() function, the
operation of those functions are not guaranteed.
By calling fca_bye(), the serial port is returned to the idle state.
For the parameters set in the structure, ser_t, refer to the rs_open
function. In case "Protocol B" is used for data transmission,
following settings are recommended.
param->baud = BAUD_4800 ;
param->stop_bit = STOP_2 ;
param->parity = PARITY_N ;
param->data_bit = DATA_8 ;
param->hardflow = 2 ;
param->dc_enable = 3 ;
param->dc_put = 0 ;
param->dc1_code = 0x11 ;
param->dc2_code = 0x12 ;
param->dc3_code = 0x93 ;
param->dc4_code = 0x14 ;
[Example]
Refer to the example in "Read binary data from the file.(fca_read)".
------------------------------------------------------------------------------
2. Close communication line. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fca_bye
[Syntax]
#include <bios.h>
int fca_bye( int channel ) ;
[Argument]
channel Channel number. ( = 1, 2 )
[Return]
Returns zero if successful. If any error, returns non-zero value.
[Description]
This function releases the serial port which has been put in the FCA
mode by the fca_setparam() function. Signals "RS" and "ER" of the
port is set "OFF".
[Example]
Refer to the example in "Read binary data from the file.(fca_read)".
------------------------------------------------------------------------------
3. Open a binary file on FCA device. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fca_open
[Syntax]
#include <bios.h>
int fca_open( char *name, int mode ) ;
[Argument]
name File name on FCA device. (max. 17 characters)
mode Access mode. ( = 0: read, 1: write )
[Return]
Returns zero if successful. Returns -1 if any error occurs.
[Description]
This function opens a binary file in the FCA device under control.
When the character '#' is used for the first character of the argument
"name", which passes the file name of the FCA device, it is assumed
that file number is designated. Following formats are available.
(Note) This function can be used only when the device connected to
the port is FANUC Handy File. It cannot be used for FANUC
CASSETTE ADAPTOR etc..
[Example]
Refer to the example in "Read binary data from the file.(fca_read)".
------------------------------------------------------------------------------
4. Close a binary file. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fca_close
[Syntax]
#include <bios.h>
int fca_close( void ) ;
[Argument]
------
[Return]
Returns zero if successful. Returns -1 if any error occurs.
[Description]
This function closes the binary file which has been opened by
fca_open() function.
(Note) This function can be used only when the device connected to
the port is FANUC Handy File. It cannot be used for FANUC
CASSETTE ADAPTOR etc..
[Example]
Refer to the example in "Read binary data from the file.(fca_read)".
------------------------------------------------------------------------------
5. Read binary data from the file. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fca_read
[Syntax]
#include <bios.h>
int fca_read( char *buffer, unsigned int bytes ) ;
[Argument]
buffer Memory area to store read data.
bytes Number of data bytes to be read. ( = 1 - 65534 )
[Return]
Returns the number of data bytes actually read when successfully
completed. Returns -1 if any error occurs.
[Description]
When called this function reads data from the binary file opened by
the fca_open() function.
Because the FCA devices require the size of the transmitted data to
exactly match with the size of its unit input/output data block, it
can happen, when returned from this function call, that extra null
characters ('\0') are added at the end of the data read. When a value
smaller than the specified byte count is returned, it should be
assumed that the last block of the file is read by that function call.
(Note) This function can be used only when the device connected to
the port is FANUC Handy File. It cannot be used for FANUC
CASSETTE ADAPTOR etc..
[Example]
Following sample program displays the specified file in the FCA device
connected to the first channel in binary dump format.
#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>
#define BUFSIZE 256
r_para.baud = BAUD_4800 ;
r_para.stop_bit = STOP_2 ;
r_para.parity = PARITY_N ;
r_para.data_bit = DATA_8 ;
r_para.hardflow = 2 ;
r_para.dc_enable = 3 ;
r_para.dc_put = 0 ;
r_para.dc1_code = 0x11 ;
r_para.dc2_code = 0x12 ;
r_para.dc3_code = 0x93 ;
r_para.dc4_code = 0x14 ;
for ( ;; ){
ret = fca_read( buffer, bytes ) ;
if ( ret == -1 ) {
printf( "error in fca_read\n" ) ;
fca_close() ;
fca_bye( 1 ) ;
return( ret ) ;
}
for( i = 0 ; i < ret ; i++ ) {
c = buffer[ i ] ;
c &= 0x00ff ;
printf( "%02X", c ) ;
count++ ;
}
if ( ret < bytes ) {
printf( "\n" ) ;
printf( "ret = %d\n", ret ) ;
printf( "bytes = %d\n", bytes ) ;
printf( "ret < bytes\n", ret ) ;
break ;
}
}
printf( "\n" ) ;
printf( "%ld bytes\n", count ) ;
ret = fca_close() ;
if ( ret ) {
printf( "error in fca_close\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}
ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye\n" ) ;
}
return ( ret ) ;
}
------------------------------------------------------------------------------
6. Write binary data to the file. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fca_write
[Syntax]
#include <bios.h>
int fca_read( char *buffer, unsigned int bytes ) ;
[Argument]
buffer Memory area to store write data.
bytes Number of data bytes to be written. ( = 1 - 65534 )
[Return]
Returns the number of data bytes actually written when successfully
completed. Returns -1 if any error occurs.
[Description]
This function is called to write data into a binary file opened by the
fca_open() function.
Because the FCA devices require the size of the transmitted data to
exactly match with the size of its unit input/output data block, the
data is padded with null characters, '\0', when it is shorter than
the unit size. As a result, it can happen that extra null characters,
'\0', are added at the end of the destination file.
(Note) This function can be used only when the device connected to
the port is FANUC Handy File. It cannot be used for FANUC
CASSETTE ADAPTOR etc..
[Example]
Following sample program writes the NC part program of specified
program number into the device connected to the first channel as a
file with specified name.
#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>
#define BUFSIZE 256
r_para.baud = BAUD_4800 ;
r_para.stop_bit = STOP_2 ;
r_para.parity = PARITY_N ;
r_para.data_bit = DATA_8 ;
r_para.hardflow = 2 ;
r_para.dc_enable = 3 ;
r_para.dc_put = 0 ;
r_para.dc1_code = 0x11 ;
r_para.dc2_code = 0x12 ;
r_para.dc3_code = 0x93 ;
r_para.dc4_code = 0x14 ;
for (;;) {
number = BUFSIZE - 1 ;
ret = cnc_upload( (struct odbup *)(&buf), &number ) ;
if ( ret ) {
printf( "error in cnc_upload\n" ) ;
cnc_upend() ;
fca_close() ;
fca_bye( 1 ) ;
return ( ret ) ;
}
ret = fca_write( &buf[4], number ) ;
if ( ret == -1 ) {
printf( "error in fca_write\n" ) ;
cnc_upend() ;
fca_close() ;
fca_bye( 1 ) ;
return ( ret ) ;
}
for ( i = 0 ; i < number ; i++ ) {
printf( "%c", buf[4+i] ) ;
}
if ( buf[4+number-1] == '%' ) {
printf( "\n" ) ;
break ;
}
}
ret = cnc_upend() ;
if ( ret ) {
printf( "error in cnc_upend\n" ) ;
fca_close() ;
fca_bye( 1 ) ;
return ( ret ) ;
}
ret = fca_close() ;
if ( ret ) {
printf( "error in fca_close\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}
ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye\n" ) ;
}
return ( ret ) ;
}
------------------------------------------------------------------------------
7. Open a text file on FCA device. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fca_fopen
[Syntax]
#include <bios.h>
int fca_fopen( char *name, char *mode ) ;
[Argument]
name File name on FCA device. (max. 17 characters)
mode Access mode. ( = "r": read, "w": write )
[Return]
Returns zero if successful. Returns -1 if any error occurrs.
[Description]
This function opens a text file in the FCA device under control.
When the character '#' is used for the first character of the argument
"name", which passes the file name of the FCA device, it is assumed
that file number is designated. Following formats are available.
(Note) When MS-DOS format is used in the FANUC Handy File, this
function cannot be used. ISO code and EIA code are the only
codes that this function and fca_putc() and fca_getc()
functions can handle.
[Example]
Refer to the example in "Read a character from the text file.
(fca_getc)".
------------------------------------------------------------------------------
8. Close a text device. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fca_fclose
[Syntax]
#include <bios.h>
int fca_fclose( void ) ;
[Argument]
------
[Return]
Returns zero if successful. Returns -1 if any error occurrs.
[Description]
This function closes the text file which has been opened by
fca_open() function.
(Note) When MS-DOS format is used in the FANUC Handy File, this
function cannot be used. ISO code and EIA code are the only
codes that this function and fca_putc() and fca_getc()
functions can handle.
[Example]
Refer to the example in "Read a character from the text file.
(fca_getc)".
------------------------------------------------------------------------------
9. Read a character from the text file. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fca_getc
[Syntax]
#include <bios.h>
int fca_getc( void ) ;
[Argument]
------
[Return]
Returns the number of characters read when successful. Return -1 if
any error occurrs or EOF is detected.
[Description]
When called, this function reads one character from the text file
opened by the fca_fopen() function.
(Note) When MS-DOS format is used in the FANUC Handy File, this
function cannot be used. ISO code and EIA code are the only
codes that this function can handle.
[Example]
Following sample program reads and displays a file, character by
character, from the device connected to the first channel.
#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>
ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye\n" ) ;
}
return ( ret ) ;
}
------------------------------------------------------------------------------
10. Write a character to the text file. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fca_putc
[Syntax]
#include <bios.h>
int fca_putc( int c ) ;
[Argument]
c A character data to be written.
[Return]
Returns the written character if successful. Returns -1 if any error
occurrs.
[Description]
When called, this function writes one character into the text file
opened by the fca_fopen() function.
(Note) When MS-DOS format is used in the FANUC Handy File, this
function cannot be used. ISO code and EIA code are the only
codes that this function can handle.
[Example]
Following sample program writes the NC part program of specified
program number, character by character, into the device connected to
the first channel as a file with the specified name.
#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>
#define BUFSIZE 256
r_para.baud = BAUD_4800 ;
r_para.stop_bit = STOP_2 ;
r_para.parity = PARITY_N ;
r_para.data_bit = DATA_8 ;
r_para.hardflow = 2 ;
r_para.dc_enable = 3 ;
r_para.dc_put = 0 ;
r_para.dc1_code = 0x11 ;
r_para.dc2_code = 0x12 ;
r_para.dc3_code = 0x93 ;
r_para.dc4_code = 0x14 ;
for (;;) {
number = BUFSIZE - 1 ;
ret = cnc_upload( (struct odbup *)(&buf), &number ) ;
if ( ret ) {
printf( "error in cnc_upload\n" ) ;
cnc_upend() ;
fca_fclose() ;
fca_bye( 1 ) ;
return ( ret ) ;
}
ret = cnc_upend() ;
if ( ret ){
printf( "error in cnc_upend()\n" ) ;
fca_fclose() ;
fca_bye( 1 ) ;
return ( ret ) ;
}
ret = fca_fclose() ;
if ( ret ) {
printf( "error in fca_close()\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}
ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye()\n" ) ;
}
return ( ret ) ;
}
------------------------------------------------------------------------------
11. Delete a file on FCA device. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fca_delete
[Syntax]
#include <bios.h>
int fca_delete( char *name ) ;
[Argument]
name Name of the file to be deleted. (max. 17 characters)
[Return]
Returns zero if successful. Returns -1 if any error occurrs.
[Description]
This function deletes a file from the FCA device.
When the character '#' is used for the first character of the argument
"name", which passes the file name of the FCA device, it is assumed
that file number is designated.
[Example]
Following sample program deletes the specified file from the FCA
device connected to the first channel.
#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>
ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye\n" ) ;
}
return ( ret ) ;
}
------------------------------------------------------------------------------
12. Change name of a file on FCA device. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fca_rename
[Syntax]
#include <bios.h>
int fca_rename( char *oldname, char *newname ) ;
[Argument]
oldname Old file name. (max. 17 characters)
newname New file name. (max. 17 characters)
[Return]
Returns zero if successful. Returns -1 if any error occurrs.
[Description]
This function changes the name of the file in the FCA devices.
[Example]
Following sample program changes the name of the specified file in the
device connected to the first channel.
#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>
ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye\n" ) ;
}
return ( ret ) ;
}
------------------------------------------------------------------------------
13. Read directory information of FCA device. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fca_readdir
[Syntax]
#include <bios.h>
int fca_readdir( fca_dir *buffer, int ndir, int NFILE ) ;
typedef struct {
char file_name[18] ;/* file name (max. 17 alpha numeric */
/* characters+null) */
/* first byte:0xFF->not used */
/* :0x00->deleted file */
char file_size[9] ; /* file size(8 digit + null character) */
char wrt_protect ; /* write protect */
/* 'P'-> ON */
/* ' '-> OFF */
char record_code ; /* code */
/* 'B'->Binary */
/* 'E'->EIA */
/* ' '->ISO */
char vol_no[3] ; /*volume number(2 digit+null character)*/
/* ' '->single volume */
char multi_vol ; /* multi volume */
/* ' '->single volume */
/* 'C'->succeeding volume exists */
/* 'L'->last volume */
} fca_dir;
[Argument]
buffer Pointer to the buffer which directory information is
stored in.
ndir Starting file number.
NFILE Number of files to read.
[Return]
Returns the number of directory information read if successful.
Returns -1 if any error occurrs.
[Description]
This function acquires the directory information from the FCA devices.
[Example]
Following sample program acquires and displays the directory
information of the device connected to the first channel.
#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>
r_para.baud = BAUD_4800 ;
r_para.stop_bit = STOP_2 ;
r_para.parity = PARITY_N ;
r_para.data_bit = DATA_8 ;
r_para.hardflow = 2 ;
r_para.dc_enable = 3 ;
r_para.dc_put = 0 ;
r_para.dc1_code = 0x11 ;
r_para.dc2_code = 0x12 ;
r_para.dc3_code = 0x93 ;
r_para.dc4_code = 0x14 ;
ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye\n" ) ;
}
return ( ret ) ;
}
------------------------------------------------------------------------------
14. Read status information of FCA device. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fca_status
[Syntax]
#include <bios.h>
int fca_status( char *buffer ) ;
[Argument]
buffer Memory area to store status information.
(Two bytes are required for this area.)
[Return]
Returns zero if successful. Returns -1 if any error occurrs.
[Description]
This function reads status information of the FCA devices.
[Example]
Refer to the example in "Delete a file on FCA device.(fca_delete)".
------------------------------------------------------------------------------
15. Read free space size of a floppy disk. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
fca_remains
[Syntax]
#include <bios.h>
int fca_remains( long *remains ) ;
[Argument]
remains Memory area to store the amount of remaining free
space of Floppy Disk.
[Return]
Returns zero if successful. Returns -1 if any error occurrs.
[Description]
This function reads the amount of remaining free space ( byte count of
the free space) in Floppy Disk.
(Note) When using MS-DOS format on FANUC Handy File, file size
differs from that given by a personal computer.
[Example]
Following sample program reads and displays the amount of remaining
free Tsapce in the Floppy Disk connected to the first channel.
#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>
ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye\n" ) ;
}
return ( ret ) ;
}
3.11 F-ROM Library
==================
Library outline
~~~~~~~~~~~~~~~
Included in the F-ROM Library are the functions which are used to read the
data files for the C Executor that are stored in the Flush ROM Module for
FS30i (referred to as "F-ROM" hereafter). The data file for the C
Executor (referred to as "C Executor data file" hereafter) is the file with
the format which can be read by the C Executor applications.
There are following three types of C Executor related files which are stored
in the F-ROM.
+--------------------------------------+
| |
| |
| C Executor program |
| |
| |
+--------------------------------------+
This type is composed of a C Executor program file and C Executor data files
combined together.
+--------------------------------------+
| |
| |
| C Executor program |
| |
| |
+--------------------------------------+
| Data file |
| directory entry |
+--------------------------------------+
| Data file 1 |
+--------------------------------------+
| Data file 2 |
+--------------------------------------+
| : |
| : |
| : |
+--------------------------------------+
| Data file n |
+--------------------------------------+
A C Executor application program is compiled and converted to the memory
card format file. Then, Data files are combined to the C Executor program
file by executing "dat2mem.com". When power is applied to the CNC, only
program part of this type of file is loaded into D-RAM to run.
+--------------------------------------+
| Data file |
| directory entry |
+--------------------------------------+
| Data file 1 |
+--------------------------------------+
| Data file 2 |
| |
+--------------------------------------+
| : |
| : |
| : |
| : |
| : |
+--------------------------------------+
| Data file n |
+--------------------------------------+
[Note] Do not call these library functions while the PMC pages are displayed
on the screen. This limitation comes from the F-ROM access
arbitration process.
--------------------------------------------------------------------------
Name Function
--------------------------------------------------------------------------
1. aux_from_open Open the specified F-ROM file.
2. aux_from_close Close the F-ROM file.
3. aux_from_select Select data in the F-ROM file.
4. aux_from_moveptr Move read pointer.
5. aux_from_read Read data from the F-ROM file.
6. aux_from_getdir Read directory information of a F-ROM file.
7. aux_from_getinfo Read F-ROM file information.
8. aux_from_getc Read a character from the F-ROM file.
9. aux_from_gets Read a line from the F-ROM file.
--------------------------------------------------------------------------
Function reference
~~~~~~~~~~~~~~~~~~
------------------------------------------------------------------------------
1. Open the specified F-ROM file. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
aux_from_open
[Syntax]
#include <bios.h>
int aux_from_open( char *filename, char *mode ) ;
[Argument]
filename Specify the name of the C Executor file in F-ROM to
open.
mode Specify access mode.
Mode should always be read mode, "r".
[Return]
Returns zero if successful. Returns non-zero value if any error
occurs. Error occurs in the following cases.
* When the specified file does not exist.
* When the F-ROM file is already opened by aux_from_open() function.
* When the F-ROM file is already being accessed by another
application.
[Description]
This function opens a C Executor file in the F-ROM and makes it ready
to be read.
The F-ROM file which can be opened by this function is C Executor file
only. Following F-ROM file names can be specified.
F-ROM file name has to be specified only by upper case letters. Also,
the name should be specified in exactly eight characters. In case a
file name is shorter than 8 characters, add space characters (20H) to
make it 8 character long.
------------------------------------------------------------------------------
2. Close the F-ROM file. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
aux_from_close
[Syntax]
#include <bios.h>
int aux_from_close( void ) ;
[Argument]
------
[Return]
Returns zero if successful. Returns non-zero value if any error
occurs. Error occurs in the following case.
* When no F-ROM file is opened by aux_from_open() function.
[Description]
This function closes an opened C Executor file.
------------------------------------------------------------------------------
3. Select data in the F-ROM file. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
aux_from_select
[Syntax]
#include <bios.h>
int aux_from_select( char *name ) ;
[Argument]
name Specify file name to be selected.
[Return]
Returns zero if successful. Returns non-zero value if any error
occurs. Error occurs in the following case.
* When specified file does not exist.
[Description]
This function selects one of the data files in the C Executor data
file.
[Name]
aux_from_moveptr
[Syntax]
#include <bios.h>
int aux_from_moveptr( long offset, int origin ) ;
[Argument]
offset Byte count from base point.
origin Base point, see description.
[Return]
Returns zero if successful. Returns non-zero value if any error
occurs. Error occurs in the following cases.
* When pointer is moved backward beyond top of file
* When pointer is moved forward beyond end of file.
[Description]
This function moves the position of the read pointer on currently
selected file.
[Name]
aux_from_read
[Syntax]
#include <bios.h>
int aux_from_read( unsigned char *buffer, unsigned int size ) ;
[Argument]
buffer Buffer area to store read data.
size Size of the data to be read.
[Return]
Returns size of the data being read if successful. Returns zero if
any error occurs.
[Description]
This function reads data from the selected data file and stores the
data in the specified buffer area.
Before calling this function, a data file, which data is read from,
must be selected by aux_from_select() function.
------------------------------------------------------------------------------
6. Read directory information of a F-ROM file. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
aux_from_getdir
[Syntax]
#include <bios.h>
int aux_from_getdir( struct infodir *buf, unsigned int *num ) ;
struct infodir {
char name[13] ; /* file name */
char reserve_1[3] ; /* reserved(not used) */
unsigned long address ; /* address of the first byte of
the file */
unsigned long size ; /* file size */
char reserve_2[8] ; /* reserved(not used) */
} ;
[Argument]
buf Area to store directory information.
num Area to store the number of directory entry.
[Return]
Returns zero if successful, and returns non-zero value if any error
occurs.
[Description]
This function reads the directory information contained in C Executor
data file.
When "NULL" is specified for "buf", only the number of directory entry
is read and stored in "num".
Directory information for one data file occupies 32 bytes.
------------------------------------------------------------------------------
7. Read F-ROM file information. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
aux_from_getinfo
[Syntax]
#include <bios.h>
int aux_from_getinfo( char *name ) ;
[Argument]
name C Executor file name in the F-ROM.
[Return]
Returns following value if successful.
CEXEC C Executor program file
CEXEC_DATA C Executor program file + C Executor data file
C_DATA C Executor data file
[Description]
This function reads information about files stored in the F-ROM.
F-ROM file name has to be specified only by upper case letters. Also,
the name should be specified in exactly eight characters. In case a
file name is shorter than 8 characters, add space characters (20H) to
make it 8 character long.
------------------------------------------------------------------------------
8. Read a character from the F-ROM file. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
aux_from_getc
[Syntax]
#include <bios.h>
unsigned int aux_from_getc( void ) ;
[Argument]
------
[Return]
Return the character being read if successful. Returns 0xFF if any
error occurs.
[Description]
This function gets one character from selected data file.
[Name]
aux_from_gets
[Syntax]
#include <bios.h>
int aux_from_gets( unsigned char *buffer, unsigned int size ) ;
[Argument]
buffer Buffer area to store data being read.
size Data size to be read.
[Return]
Returns zero if successful. Returns -1 if any error occurs.
[Description]
This function reads one line of data from the selected data file and
stores the data in the specified buffer area.
A line is made up with all characters read before Line Feed character
('\n'). Line Feed character being read is stored in the buffer.
A null character ('\0') is added at the end of the line.
Reading character continues until Line Feed character ('\n) is
encountered, end of file is detected or "size - 1" number of
characters are read. This function replaces line termination code,
"Carriage Return + Line Feed ( CR + LF)", with single Line Feed
character LF.
Before calling this function, a data file, which data is read from,
must be selected by aux_from_select() function.
[Example 1]
/*
Select a file, TEST02.DAT, read and display 10 bytes of data
from the beginning of the file. Then move read pointer 50 bytes
ahead of current position, and read and display 50 bytes of data.
int i, ret ;
unsigned char read_buf[SIZE] ;
int read_size, offset ;
if ( aux_from_open( "CEX 1.0M", "r" ) ) {
printf( "Failed opening file\n" ) ;
}
else {
if ( aux_from_select( "TEST02.DAT" ) ) {
printf( "specified file not exist\n" ) ;
}
else {
read_size = 10 ;
ret = aux_from_read( read_buf, read_size ) ;
if (ret != 0 ) {
for ( i=0 ; i<ret ; i++) {
printf( "%c", read_buf[i] ) ;
}
}
printf( "\n---move pointer---\n" );
offset = 50 ;
if ( aux_from_moveptr( offset, FROM_SEEK_CUR ) ) {
printf( "Failed moving pointer\n" ) ;
}
else {
read_size = 50 ;
ret = aux_from_read( read_buf, read_size ) ;
if (ret != 0 ) {
for ( i=0 ; i<ret ; i++) {
printf( "%c", read_buf[i] ) ;
}
}
}
}
aux_from_close() ;
}
}
[Example 2]
/*
Open F-ROM file of combined C Executor program file and C Executor
data file and display directory list.
*/
void sample2() {
*/
void sample3() {
int file_type ;
Overview of library
~~~~~~~~~~~~~~~~~~~
1. Overview
In case that the display device is "10.4-inch LCD with touch-panel", the C
application can read status of the touch-panel. The information to be read
is;
2. Touch-panel coordinate
The touch-panel library uses the following X-Y coordinate system whose
origin is put at the upper-left point to represent points on the touch-panel.
----> X
| +-----------------------------------+
| |(0,0) |
v | |
Y | |
| |
| |
| |
| |
| |
| |
| |
| |
| (xxxx,yyyy)|
+-----------------------------------+
+-----------------------------------+ -----
|(0,0) | ^
+-----------------------------------+ -- |
|(0,48) | ^ |
| | | |
| | | |
| | | |
| | B A
| | | |
| | | |
| (639,447)| v |
+-----------------------------------+ -- |
| (639,479)| v
+-----------------------------------+ -----
B: 640x400 dots
X(touch-panel) = X(graphic)
Y(touch-panel) = Y(graphic) + 48
[Note]
The touch-panel can sense only one point at a time. When multiple
points are pushed simultaneously, the center point of all pushed
points (in consideraton of each pressure) is read. For example,
when (100,100) and (200,300) are pushed simultaneously, touch-panel
senses that somewhere between (100,100) and (200,300) is pushed.
This is caused by the physical specification (analog sensing) of
the touch-panel.
List of Functions
~~~~~~~~~~~~~~~~~
----------------------------------------------------------------------
Name Function
----------------------------------------------------------------------
1. aux_tpl_read Read the status and (X,Y) coordinate of the
touch-panel.
----------------------------------------------------------------------
Function Reference
~~~~~~~~~~~~~~~~~~
------------------------------------------------------------------------------
1. Read the status and (X,Y) coordinate of the touch-panel. <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
aux_tpl_read
[Syntax]
#include <bios.h>
int aux_tpl_read( struct tpl_xy_coord *buf ) ;
struct tpl_xy_coord {
unsigned int tpl_x_coord ; /* X-coordinate */
unsigned int tpl_y_coord ; /* Y-coordinate */
} ;
[Argument]
buf X-Y coordinate structure of touch-panel.
[Return]
0x80 - 0x82
Touch-panel is being pushed.
0x00 Touch-panel is not being pushed, or any error occurs.
[Description]
Reads the touch-panel status and the coordinate value of the pushed
point when touch-panel is pushed.
One of 0x80, 0x81 or 0x82 is returned as the return value when the
touch-panel is pushed. The difference of these values is as follows.
Value Status
-------+---------------------------------------------------
0x80 Start pushing. (received HEAD data)
0x81 Keep pushing. (received BODY data)
0x82 End pushing. received TAIL data)
Value Status
-------+---------------------------------------------------
0x88 Received HEAD data.
0x89 Received BODY data.
0x8A Received TAIL data.
That is, the bit3 of the return value indicates that the no-calibrated
coordinate data are received.
#include <bios.h>
#include <stdio.h>
4.1.1 Keycode
+----+------+------+------+------+------+------+-------+------+
| | 0x | 1x | 2x | 3x | 4x | 5x | 6x | 7x |
|----+------+------+------+------+------+------+-------+------|
| x0 | | | SP | 0 | @ | P | | |
| x1 | | | | 1 | A | Q | | |
| x2 | | | | 2 | B | R | | |
| x3 | | | # | 3 | C | S | | |
| x4 | | | | 4 | D | T | | |
| x5 | | | | 5 | E | U | | |
| x6 | | | & | 6 | F | V | | |
| x7 | | | | 7 | G | W | | |
| x8 | CAN | | ( | 8 | H | X | | |
| x9 | | | ) | 9 | I | Y | | |
| xA | EOB | | * | | J | Z | | |
| xB | | | + | | K | [ | | |
| xC | | | , | | L | | | |
| xD |INPUT | | - | = | M | ] | | |
| xE | | | . | | N | | | |
| xF | | | / | ? | O | | | |
+----+------+------+------+------+------+------+-------+------+
+----+------+------+------+------+------+------+-------+------+
| | 8x | 9x | Ax | Bx | Cx | Dx | Ex | Fx |
|----+------+------+------+------+------+------+-------+------|
| x0 | |RESET | | | | | |F0 |
| x1 | | | | | | | |F1 |
| x2 | | | | | | | |F2 |
| x3 | | | | | | | |F3 |
| x4 | |INSERT| | | | | |F4 |
| x5 | |DELETE| | | | | |F5 |
| x6 | |ALTER | | | | | |F6 |
| x7 | | | | | | | |F7 |
| x8 |Curs->| | | | | | POS |F8 |
| x9 |Curs<-| | | | | | PROG |F9 |
| xA |CursDn| HELP | | | | |OFFSET | |
| xB |CursUp| | | | | |SYSTEM | |
| xC | | | | | | |MESSAG | |
| xD | | | | | | |GRAPH | |
| xE |PageDn| | | | | |CUSTOM | FR |
| xF |PageUp| | | | | |CUSTOM2| FL |
+----+------+------+------+------+------+------+-------+------+
- Usage : For example, the keycode for the key 'A' is given as "41"
(hex) by combining "4x" and "x1".
- SP stands for space(white space).
- Function keys or screen selection keys, POS .. CUSTOM, usually
cannot be read from application program.
- Keys F0 .. F9,FR,FL are soft-keys.
4.1.2 Keycode of special keys on MDI panel
Escape
sequence Function
---------------+-------------------------------------------------------
ESC [H Move cursor to the home position.
ESC [l;cH Move cursor to the c th column of the first line.
(upper left corner of the screen is addressed as
line 1, column 1)
ESC [nA Move cursor up n lines. (move 1 line if n is omitted.)
ESC [nB Move cursor down n lines. (move 1 line if n is
omitted.)
ESC [nC Move cursor right n columns. (move 1 column if n is
omitted.)
ESC [nD Move cursor left n columns. (move 1 column if n is
omitted.)
ESC D Move cursor down 1 line. Scroll up one line if cursor
is at the bottom line.
ESC E Move cursor to the left most column of the next line.
Scroll up one line if cursor is at the bottom line.
ESC M Move cursor up 1 line. Scroll down one line if cursor
is at the top line.
ESC [s Save current cursor position.
ESC [u Restore cursor to the position saved by "ESC [s".
(2) Deleting
Escape
sequence Function
---------------+-------------------------------------------------------
ESC [K Delete from current cursor position to end of line.
ESC [0K Same as above.
ESC [1K Delete from current cursor position to beginning of
line.
ESC [2K Delete current line.
ESC [J Delete from current cursor position to end of screen.
ESC [0J Same as above.
ESC [1J Delete from current cursor position to beginning of
screen.
ESC [2J Delete whole screen.
Escape
sequence Function
---------------+-------------------------------------------------------
ESC [nL Scroll current cursor line and succeeding lines down n
lines, insert n blank lines and move cursor to the
beginning of the first newly inserted blank line.
ESC [nM Delete n lines beginning from current cursor line to
downward, scroll up following lines and move cursor to
the beginning of the first line of those scrolled up.
Escape
sequence Function
---------------+-------------------------------------------------------
ESC [7h Turn on automatic wrapping around. (Default)
ESC [?7h Same as above.
ESC [7l Turn off automatic wrapping around.
ESC [?7l Same as above.
ESC [>5l Make cursor visible. (Default)
ESC [>5h Make cursor invisible.
ESC [>9l Output video signals to CRT. (Default)
ESC [>9h Not output video signals to CRT.
(5) Character attribute
Escape
sequence Function
---------------+-------------------------------------------------------
ESC [0m Restore default attribute. (White, no blinking, no
reverse video)
ESC [5m Turn on blinking.
ESC [7m Turn on reverse video mode.
ESC [25m Turn off blinking.
ESC [27m Turn off reverse video mode.
ESC [30m Black.
ESC [31m Red.
ESC [32m Green.
ESC [33m Yellow.
ESC [34m Blue.
ESC [35m Magenta.
ESC [36m Cyan.
ESC [37m White.
Escape
sequence Function
---------------+-------------------------------------------------------
ESC [1m Turn on low intensity color.
ESC [2m Don't draw background part of character.
ESC [3m Turn on low intensity color for background.
ESC [21m Draw background part of character. (Default)
ESC [22m Turn off low intensity color.
ESC [23m Turn off low intensity color for background.
ESC [40m Background black.
ESC [41m Background red.
ESC [42m Background green.
ESC [43m Background yellow.
ESC [44m Background blue.
ESC [45m Background magenta.
ESC [46m Background cyan.
ESC [47m Background white.
On VGA display device, actual displayed colors for each escape
sequence are defined by setting of color palettes for character
display. The color palettes for character display are changeable
by crt_setpalette function.
(6) Selecting character set
Escape
sequence Function
---------------+-------------------------------------------------------
ESC (1 Select special characters and fragment set of 6x
magnified numeric characters.
ESC (2 Select fragment set of 6x magnified alphabetic
characters.
ESC (3 Select graphic character set.
ESC (4 Select standard character set. (Default)
ESC (6 Select 6x magnified character set.
ESC (7 Select European character set (umlaut etc.)
ESC (8 Select user defined character set.
ESC (A Select JIS Kanji character set (Shift-JIS code).
ESC (B Select FANUC Kanji character set (Shift-JIS code).
(Default)
ESC (C Select FANUC Kanji character set(Shift-FANUC code).
ESC (a Select JIS character set (half-size, large font).
ESC (b Select JIS character set (half-size, small font).
ESC (E Select 9-inch font.
ESC (F Select 14-inch font. (Default)
4.2 Displayable characters
==========================
(Note) Mesh mark is displayed for the character code 7F, and wave mark for A0.
Above is the code table for the standard character set. ( "ESC (4" )
Following KANJI characters of JIS 1st level character set are available in
C Executor. The characters in parentheses cannot be displayed. If these
characters are output, double width space is displayed instead. FANUC original
special marks are assigned to 885F through 889D of SJIS code. These special
marks are described later.
-------------------------------------------------------------------
CHARACTER TABLE IS NOT LISTED IN THIS FILE.
SEE "42CHAR_J.MAN" FOR JAPANESE KANJI CHARACTER SET.
-------------------------------------------------------------------
Only following Kanji characters in JIS 2nd level character set are available
for display. If JIS 2nd level Kanji characters other than following are output,
double width space is displayed instead.
-------------------------------------------------------------------
CHARACTER TABLE IS NOT LISTED IN THIS FILE.
SEE "42CHAR_J.MAN" FOR JAPANESE KANJI CHARACTER SET.
-------------------------------------------------------------------
(3) FANUC special marks
The FANUC special marks which are assigned to JIS 1st level character set
code are shown below.
The DIAB-SDS compiler does not support Japanese language. If a 2-byte charac-
ter whose second byte happens to be 5Ch is included directly in a source file,
it is not recognized as correct data.
-------------------------------------------------------------------
CHARACTER TABLE IS NOT LISTED IN THIS FILE.
SEE "42CHAR_J.MAN" FOR JAPANESE KANJI CHARACTER SET.
-------------------------------------------------------------------
-------------------------------------------------------------------
CHARACTER TABLE IS NOT LISTED IN THIS FILE.
SEE "42CHAR_J.MAN" FOR JAPANESE KANJI CHARACTER SET.
-------------------------------------------------------------------
4.2.3 Display code for single byte characters
In the following tables, the code of the FANUC characters in each character
set selected by the escape sequences, "ESC (x", are shown. . If , for example,
0x20 (space) is output in the "ESC (1" mode, FANUC character of the code
0x00E0 is displayed on the screen.
+----+------+------+------+------+------+------+------+------+------+------+
| | 2x | 3x | 4x | 5x | 6x | 7x | Ax | Bx | Cx | Dx |
|----+------+------+------+------+------+------+------+------+------+------|
| x0 | 00E0 | 00F8 | 0108 | 0118 | 0128 | 0138 | | 0760 | 0770 | 01F0 |
| x1 | 00E1 | 00F9 | 0109 | 0119 | 0129 | 0139 | | 0761 | 0771 | 01F1 |
| x2 | 00E2 | 00FA | 010A | 011A | 012A | 013A | 0752 | 0762 | 0772 | 01F2 |
| x3 | 00E3 | 00FB | 010B | 011B | 012B | 013B | 0753 | 0763 | 0773 | 01F3 |
| x4 | 00E4 | 00FC | 010C | 011C | 012C | 01D8 | 0754 | 0764 | 01E4 | 01F4 |
| x5 | 00E5 | 00FD | 010D | 011D | 012D | 01D9 | 0755 | 0765 | 01E5 | 01F5 |
| x6 | 00E6 | 00FE | 010E | 011E | 012E | 01DA | 0756 | 0766 | 01E6 | 01F6 |
| x7 | 00E7 | 00FF | 010F | 011F | 012F | 01DB | 0757 | 0767 | 01E7 | 01F7 |
| x8 | 00F0 | 0100 | 0110 | 0120 | 0130 | 01DC | 0758 | 0768 | 01E8 | 01F8 |
| x9 | 00F1 | 0101 | 0111 | 0121 | 0131 | 01DD | 0759 | 0769 | 01E9 | 01F9 |
| xA | 00F2 | 0102 | 0112 | 0122 | 0132 | 01DE | 075A | 076A | 01EA | 01FA |
| xB | 00F3 | 0103 | 0113 | 0123 | 0133 | 01DF | 075B | 076B | 01EB | 01FB |
| xC | 00F4 | 0104 | 0114 | 0124 | 0134 | 01E0 | 075C | 076C | 01EC | 01FC |
| xD | 00F5 | 0105 | 0115 | 0125 | 0135 | 01E1 | 075D | 076D | 01ED | 01FD |
| xE | 00F6 | 0106 | 0116 | 0126 | 0136 | 01E2 | 075E | 076E | 01EE | 01FE |
| xF | 00F7 | 0107 | 0117 | 0127 | 0137 | 01E3 | 075F | 076F | 01EF | 01FF |
+----+------+------+------+------+------+------+------+------+------+------+
+----+------+------+------+------+------+------+------+------+------+------+
| | 2x | 3x | 4x | 5x | 6x | 7x | Ax | Bx | Cx | Dx |
|----+------+------+------+------+------+------+------+------+------+------|
| x0 | 1D50 | 1D60 | 1D70 | 1D80 | 1D90 | 1DA0 | 1DB0 | 1DC0 | 1DD0 | 1DE0 |
| x1 | 1D51 | 1D61 | 1D71 | 1D81 | 1D91 | 1DA1 | 1DB1 | 1DC1 | 1DD1 | 1DE1 |
| x2 | 1D52 | 1D62 | 1D72 | 1D82 | 1D92 | 1DA2 | 1DB2 | 1DC2 | 1DD2 | 1DE2 |
| x3 | 1D53 | 1D63 | 1D73 | 1D83 | 1D93 | 1DA3 | 1DB3 | 1DC3 | 1DD3 | 1DE3 |
| x4 | 1D54 | 1D64 | 1D74 | 1D84 | 1D94 | 1DA4 | 1DB4 | 1DC4 | 1DD4 | 1DE4 |
| x5 | 1D55 | 1D65 | 1D75 | 1D85 | 1D95 | 1DA5 | 1DB5 | 1DC5 | 1DD5 | 1DE5 |
| x6 | 1D56 | 1D66 | 1D76 | 1D86 | 1D96 | 1DA6 | 1DB6 | 1DC6 | 1DD6 | 1DE6 |
| x7 | 1D57 | 1D67 | 1D77 | 1D87 | 1D97 | 1DA7 | 1DB7 | 1DC7 | 1DD7 | 1DE7 |
| x8 | 1D58 | 1D68 | 1D78 | 1D88 | 1D98 | 1DA8 | 1DB8 | 1DC8 | 1DD8 | 1DE8 |
| x9 | 1D59 | 1D69 | 1D79 | 1D89 | 1D99 | 1DA9 | 1DB9 | 1DC9 | 1DD9 | 1DE9 |
| xA | 1D5A | 1D6A | 1D7A | 1D8A | 1D9A | 1DAA | 1DBA | 1DCA | 1DDA | 1DEA |
| xB | 1D5B | 1D6B | 1D7B | 1D8B | 1D9B | 1DAB | 1DBB | 1DCB | 1DDB | 1DEB |
| xC | 1D5C | 1D6C | 1D7C | 1D8C | 1D9C | 1DAC | 1DBC | 1DCC | 1DDC | 1DEC |
| xD | 1D5D | 1D6D | 1D7D | 1D8D | 1D9D | 1DAD | 1DBD | 1DCD | 1DDD | 1DED |
| xE | 1D5E | 1D6E | 1D7E | 1D8E | 1D9E | 1DAE | 1DBE | 1DCE | 1DDE | 1DEE |
| xF | 1D5F | 1D6F | 1D7F | 1D8F | 1D9F | 1DAF | 1DBF | 1DCF | 1DDF | 1DEF |
+----+------+------+------+------+------+------+------+------+------+------+
+----+------+------+------+------+------+------+------+------+------+------+
| | 2x | 3x | 4x | 5x | 6x | 7x | Ax | Bx | Cx | Dx |
|----+------+------+------+------+------+------+------+------+------+------|
| x0 | 0020 | 0030 | 0040 | 0050 | 0F80 | 0F90 | 00A0 | 00B0 | 00C0 | 00D0 |
| x1 | 0021 | 0031 | 0041 | 0051 | 0F81 | 0F91 | 00A1 | 00B1 | 00C1 | 00D1 |
| x2 | 0022 | 0032 | 0042 | 0052 | 0F82 | 0F92 | 00A2 | 00B2 | 00C2 | 00D2 |
| x3 | 0023 | 0033 | 0043 | 0053 | 0F83 | 0F93 | 00A3 | 00B3 | 00C3 | 00D3 |
| x4 | 0024 | 0034 | 0044 | 0054 | 0F84 | 0F94 | 00A4 | 00B4 | 00C4 | 00D4 |
| x5 | 0025 | 0035 | 0045 | 0055 | 0F85 | 0F95 | 00A5 | 00B5 | 00C5 | 00D5 |
| x6 | 0026 | 0036 | 0046 | 0056 | 0F86 | 0F96 | 00A6 | 00B6 | 00C6 | 00D6 |
| x7 | 0027 | 0037 | 0047 | 0057 | 0F87 | 0F97 | 00A7 | 00B7 | 00C7 | 00D7 |
| x8 | 0028 | 0038 | 0048 | 0058 | 0F88 | 0F98 | 00A8 | 00B8 | 00C8 | 00D8 |
| x9 | 0029 | 0039 | 0049 | 0059 | 0F89 | 0F99 | 00A9 | 00B9 | 00C9 | 00D9 |
| xA | 002A | 003A | 004A | 005A | 0F8A | 0F9A | 00AA | 00BA | 00CA | 00DA |
| xB | 002B | 003B | 004B | 005B | 0F8B | 0F9B | 00AB | 00BB | 00CB | 00DB |
| xC | 002C | 003C | 004C | 005C | 0F8C | 0F9C | 00AC | 00BC | 00CC | 00DC |
| xD | 002D | 003D | 004D | 005D | 0F8D | 0F9D | 00AD | 00BD | 00CD | 00DD |
| xE | 002E | 003E | 004E | 005E | 0F8E | 0F9E | 00AE | 00BE | 00CE | 00DE |
| xF | 002F | 003F | 004F | 005F | 0F8F | 0F9F | 00AF | 00BF | 00CF | 00DF |
+----+------+------+------+------+------+------+------+------+------+------+
(5) "ESC (6" Fragments of 6x magnified characters
+----+------+------+------+------+------+------+------+------+------+------+
| | 2x | 3x | 4x | 5x | 6x | 7x | Ax | Bx | Cx | Dx |
|----+------+------+------+------+------+------+------+------+------+------|
| x0 | | 0100 | | 0196 | | | | | | |
| x1 | | 0106 | 013C | 019C | | | | | | |
| x2 | | 010C | 0142 | 01A2 | | | 1CE0 | | | |
| x3 | | 0112 | 0148 | 01A8 | | | 1CE6 | | | |
| x4 | | 0118 | 014E | 01AE | | | 1CEC | | | |
| x5 | | 011E | 0154 | 01B4 | | | | | | |
| x6 | | 0124 | 015A | 01BA | | | | | | |
| x7 | | 012A | 0160 | 01C0 | | | | | | |
| x8 | | 0130 | 0166 | 01C6 | | | | | | |
| x9 | | 0136 | 016C | 01CC | | | | | | |
| xA | | | 0172 | 01D2 | | | | | | |
| xB | | | 0178 | | | | | | | |
| xC | | | 017E | | | | | | | |
| xD | 01D8 | | 0184 | | | | | | | |
| xE | 01DE | | 018A | | | | | | | |
| xF | | | 0190 | | | | | | | |
+----+------+------+------+------+------+------+------+------+------+------+
(*) A 6x magnified character is displayed combining 6 consecutive single byte
characters, beginning with the code in above table.
+----+------+------+------+------+------+------+------+------+------+------+
| | 2x | 3x | 4x | 5x | 6x | 7x | Ax | Bx | Cx | Dx |
|----+------+------+------+------+------+------+------+------+------+------|
| x0 | 0020 | 0030 | 0040 | 0050 | 0F80 | 0F90 | 0FC0 | 0FD0 | 0FE0 | 0FF0 |
| x1 | 0021 | 0031 | 0041 | 0051 | 0F81 | 0F91 | 0FC1 | 0FD1 | 0FE1 | 0FF1 |
| x2 | 0022 | 0032 | 0042 | 0052 | 0F82 | 0F92 | 0FC2 | 0FD2 | 0FE2 | 0FF2 |
| x3 | 0023 | 0033 | 0043 | 0053 | 0F83 | 0F93 | 0FC3 | 0FD3 | 0FE3 | 0FF3 |
| x4 | 0024 | 0034 | 0044 | 0054 | 0F84 | 0F94 | 0FC4 | 0FD4 | 0FE4 | 0FF4 |
| x5 | 0025 | 0035 | 0045 | 0055 | 0F85 | 0F95 | 0FC5 | 0FD5 | 0FE5 | 0FF5 |
| x6 | 0026 | 0036 | 0046 | 0056 | 0F86 | 0F96 | 0FC6 | 0FD6 | 0FE6 | 0FF6 |
| x7 | 0027 | 0037 | 0047 | 0057 | 0F87 | 0F97 | 0FC7 | 0FD7 | 0FE7 | 0FF7 |
| x8 | 0028 | 0038 | 0048 | 0058 | 0F88 | 0F98 | 0FC8 | 0FD8 | 0FE8 | 0FF8 |
| x9 | 0029 | 0039 | 0049 | 0059 | 0F89 | 0F99 | 0FC9 | 0FD9 | 0FE9 | 0FF9 |
| xA | 002A | 003A | 004A | 005A | 0F8A | 0F9A | 0FCA | 0FDA | 0FEA | 0FFA |
| xB | 002B | 003B | 004B | 005B | 0F8B | 0F9B | 0FCB | 0FDB | 0FEB | 0FFB |
| xC | 002C | 003C | 004C | 005C | 0F8C | 0F9C | 0FCC | 0FDC | 0FEC | 0FFC |
| xD | 002D | 003D | 004D | 005D | 0F8D | 0F9D | 0FCD | 0FDD | 0FED | 0FFD |
| xE | 002E | 003E | 004E | 005E | 0F8E | 0F9E | 0FCE | 0FDE | 0FEE | 0FFE |
| xF | 002F | 003F | 004F | 005F | 0F8F | 0F9F | 0FCF | 0FDF | 0FEF | 0FFF |
+----+------+------+------+------+------+------+------+------+------+------+
4.2.4 Kanji character code
In the "ESC (B" mode, application programs can specify Shift-JIS code Kanji
characters in character strings, similar to the MS-DOS applications.
Shift-JIS code is converted to the FANUC code internally by the library.
In the "ESC (C" mode, specified Kanji character code is converted to the FANUC
code according to the following rule. Hangul characters or graphic characters
can be displayed in this mode.
code_high -= 0x6B ;
if ( code_low >= 0x80 )
code_low -= 0x60 ;
else
code_low -= 0x40 ;
code_low <<= 1 ;
For example, by specifying the code 0x8140, the Hangul character of the FANUC
code 0x1600 is displayed on the screen.
5. Other References
===================
5.1 Multitasking
================
The main task is executed only while user screens are displayed. The alarm
task and the communication task is executed background without any relation to
the screen display.
When user application program is composed of only one task, this task should
be the main task.
(supplement) Each task class corresponds to the macro-program of the Macro
Executor as follows.
Task switching between the main task and the auxiliary task is executed by
calling task management library functions in the application program. To run
the auxiliary task periodically, the period is also specified by the
application program.
+------------------+
main task - - - - - (wait) - - - - -+ (run) + - -
^ ^
system start Event happens
+--------------------------------+
| common variable (sramver.c) |
| |---+
+--------------------------------+ |
| common variable(dramver.c) |
+---------------------------------+
v ^ v ^ v ^
+----------+ +----------+ +----------+
| | | | | |
| Main | | Alarm | |Communica-|
| task | | task | |tion task |
| | | | | | +-----------------+
| | | | | | | |
| | | | | | | |
+----------+ +----------+ +----------+ | |
v ^ v ^ v ^ | CNC control |
+------------------------------------+ | software |
| C Executor library(interface) | | |
+------------------------------------+ | |
v ^ | |
+------------------------------------+ | |
| C Executor library(kernel) | -> | |
| | <- | |
+------------------------------------+ +-----------------+
Data cannot be accessed between memory address spaces which are not
connected by arrows in above figure.
5.1.5 Task Management
Kind of tasks
* Main task
Almost all processing of the user application, such as displaying
of the user screen, are executed in this task. The TASK1 is the main
task.
* Background tasks
These tasks are usually waked by various events and they are
executed independently of the main task. The TASK2 (the communication
task) and the TASK3 (the alarm task) are background tasks. These
tasks execute the processing about the related events, then suspend
execution to wait for the next event again, and give the CPU to the
main task.
Both the main task and the background tasks are executed in the
idle CPU time which is not used by the CNC interruption tasks.
5.2 File system
===============
The File name is changed to one with capital characters and is discerned.
The following characters can be used for a File name. ( The 2 bytes characters
can not be used.)
Alphabetic characters A .. Z
Numeric characters 0 .. 9
Special characters $ & # % ' ( ) - @ ^ { } ~ ` ! _
The following Wild card characters can be used for the File name and
extension.
(example 1) "TEST?.C"
"TEST1.C" , "TEST2.C" , "TESTA.C" , "TESTB.C" etc. are applied.
(example 2) "TEST*.C"
"TEST1.C" , "TEST12.C" , "TESTA.C" , "TESTAB.C" etc. are applied.
(example 3) "TEST*A.C"
The character 'A' is neglected and so this example is the same as
example 2).
(6) Directory
For the file information, names,sizes and update times are registered in
the directory. The directory itself is a kind of files and can be layered.
The basic directory of layered directories is called "Root directory".
The Root directory is automatically created at initializing the device.
The directory created below the root one is called "Sub directory".
Within the range of the path name length(lower than 64 bytes), the Sub
directories are created in so many layers.
The number of files which the application can open simultaneously is fixed
60 as a whole. I/O Control buffers which are used by High level input/output
functions(fopen,fclose,fprintf,...) are prepared respectively 15 for each task.
At launching of each task, following three standard input/output functions
are opened.
On FS30i with C Executor, the special procedure is executed when the power
is turned on with pushing the definite MDI keys.
Key pushed
at power on Execution
---------------+-------------------------------------------------
[M] + [0] The System starts up without executing C Executor.
The CNC is executed in the same condition as no
C Executor installed. This is used for disregarding
C Executor function transiently.
[M] + [3] The System application is launched without
launching the User application.
(note)
* [M]+[0] means that [M] key and [0] key are pushed at one time. [M]+[3]
means the same.
* Please continue to push these keys till the normal NC screen or the user
screen of C Executor is displayed after power on.
5.4 Parameter setting on CNC
============================
Descriptions of parameters
Data number #7 #6 #5 #4 #3 #2 #1 #0
+--------+ +------+------+------+------+------+------+------+------+
| 8650 | | | | | CKM | | EKY | CNA | RSK |
+--------+ +------+------+------+------+------+------+------+------+
Data format : Bit type
(Note) The change of the set data becomes effective after the next
power on.
Data number Data
+--------+ +-------------------------------------------------------+
| 8661 | | Size of variable areas |
+--------+ +-------------------------------------------------------+
Data format : word type
Data unit : KByte
Data range : 0 through 59 (251)
Specify the size of the static variable areas which can be set
by each task. Specify it by the unit of 1 Kbyte. The maximum size
is 59 KBytes (251 KBytes in the case with SRAM 256 KB option).
And the total value of a SRAM Disk size and this size should not
exceed (usable SRAM size -1) KBytes (that is 63 or 255 KBytes).
(Note) When this value is changed, the contents of variable areas and
a SRAM Disk are initialized.
The change of the set data becomes effective after the next
power on.
Specify the equation of time from Greenwich time by the unit of second.
The value is -9 hours in Japan. (the value is -9*3600=-32400)
(Note) The change of the set data becomes effective after the next
power on.
(Note) The usable size is also limited by the RAM size and the
assembly of option.
5.5 Dat2mem utility manual
==========================
----------------------------------------------------
Data file to Memory_Card file conversion utility
----------------------------------------------------
+-----------------------+
| Memory_Card file |
| header |
+-----------------------+
| Data file |
| directory entry |
+-----------------------+
| Data file 1 |
| |
+-----------------------+
| Data file 2 |
| |
+-----------------------+
| ... |
| |
+-----------------------+
| Data file n |
| |
+-----------------------+
Multiple MS-DOS data files are combined in this file. F-ROM file
identification name for this type of file is "CEXnxxxx" where 'n' is a
number from 0 to 9 and "xxxx" is any combination of max. 4 alpha-
numeric characters. Ten C Executor data files ( "CEX0xxxx" --
"CEX9xxxx") can be stored in the F-ROM at maximum. Files stored in
the F-ROM are identified by using leftmost 4 characters of the
identification name. As a result, the files with identification
names "CEX1DATA" and "CEX1TEXT" are assumed as the same file. That
is, if a file "CEX1TEXT" is written to the F-ROM in which a file
"CEX1DATA" is stored, the file "CEX1DATA" is deleted and only the
file "CEX1TEXT" remains.
and the F-ROM memory blocks of 128KB unit is allocated to the file.
In this type of file are general data or machine tool dependent data
(system parameters or offset data).
+-----------------------+
| Memory_Card file |
| header |
+-----------------------+ ---
| | ^
| C Executor program | | Loaded into DRAM
| | | when power ON
| | v
+-----------------------+ ---
| Data file |
| directory entry |
+-----------------------+
| Data file 1 |
| |
+-----------------------+
| Data file 2 |
| |
+-----------------------+
| ... |
| |
+-----------------------+
| Data file n |
| |
+-----------------------+
and the F-ROM memory blocks of 128KB unit is allocated to the file.
This type of file is suited to store the data closely related to the
C Executor program, screen data for example.
For both types C Executor data file, C Executor application program opens a
C Executor data file by specifying file identification name ,"CEXnxxxx" or
"CEX xxxM", then selects and reads one of the data files in it.
In the directory entry, the "8.3 format" file name, data size and origin
address in F-ROM file for each MS-DOS files are stored. C Executor
application program can read the contents of this directory entry.
There are no specific limitations for the size or type of the MS-DOS data
file which is converted by this utility. The contents of the MS-DOS data
file is stored in the C Executor data file as it is.
"xxx" stands for the name of the Command file mentioned later.
;----------------------------------------------------------------
CEX1PARM.MEM
;----------------------------------------------------------------
c:\data\*.dat
;----------------------------------------------------------------
; end of spec file
--<< to the previous line >>--------------------------------------------------
;----------------------------------------------------------------
cexec_d.mem
;----------------------------------------------------------------
cexec.mem
;----------------------------------------------------------------
\work\scrn1.dat
\work\scrn2.dat
\text\msg.txt
;----------------------------------------------------------------
; end of spec file
--<< to the previous line >>--------------------------------------------------
(5) Error messages
"insufficient memory"
Cannot allocate enough memory to execute the program.
The program numbers are 8 digits in C language Executor for FANUC Series 30i.
It is not compatible with the application of the program number 4 digits
designed for FANUC Series 16/18.
Please change the application referring to "Conforming CNC window library
to O8-digits program number option" of the FANUC Series 16/18 C Executor
programming manual.
5.7 Window task
===============
5.7.1 Overview
C Executor system is composed of 3 tasks, Main task, Alarm task and Communi-
cation task. The Window task is fourth additional task to these 3 tasks.
+--------------------------------------------+
CNC tasks | CNC Interruption TASKs |
+--------------------------------------------+
+----------------------------+ +-------------+
+- | Alarm TASK | | |
| +----------------------------+ | |
Aux. tasks | +----------------------------+ | |
+- | Communication TASK | | Window TASK |
+----------------------------+ | |
+-------------+ +------------+ | |
Display tasks | Main TASK | | CNC TASK | | |
+-------------+ +------------+ +-------------+
The window task runs with the tree tasks of C Executor and the CNC's display
task simultaneously. This task is like the auxiliary tasks of C Executor, but
it can display to the screen unlike them. About displaying screen, the window
task is similar to the main task except that the target screen to display is
only the VGA windows. So, it is impossible to display without VGA display
device. (The execution itself is available even if any display device is
equipped.) The window task can't read MDI key unlike the main task. It can
read the status of touch-panel.
On the CNC with VGA display device, it opens VGA windows on the
screen and controls them, and receives the commands of the operator
via input signals of PMC or touch-panel.
Such as controling "Software machine control panel" on the screen with touch-
panel. It can be applied to the general purposes, but it is most suitable
task to the above purpose.
The window task is loaded on the memory with the other tasks in the power-
up sequence of CNC. This task is not automatically started. To start the
window task, call "os_strt_wtsk()" function by the main task. When this
function is executed successfully, the window task starts running simul-
taneously with the other 3 tasks and the CNC's display task.
5.7.3 Usage of the window task
(1) Start
|
(2) Initialize
|
| <---------------------+
| <----------------+ |
| | |
(3) Wait the trigger ----------+ |
to display no trigger |
| |
| |
(4) Open VGA window |
| |
| <----------------+ |
| | |
(5) Display and read commands | |
| | |
| | |
(6) If display end -----------+ |
| not end |
| |
(7) Close VGA window |
| |
+-----------------------+
(1) Start
The window task starts from "main()" function by calling
"os_strt_wtsk()" in the main task.
(2) Initialize
General initialization such as variable setting,etc.
It is possible to always open VGA windows on the screen rather than the app-
lication program opens them on demands. Also it is possible to open the
invisible VGA window.
(5) Load the created memory card file into the CNC and run it.
There is no special parameter setting about window task.
5.7.6 Notes
Take case of the followings for using window task.
The task number of the window task is '4'. The window task is called
"TASK4". All tasks of whole application including window task are as
below.
5.8.1 Overview
For both CNCs, it is possible to display on the virtual CNC screen displayed
on PC's screen by "CNC screen display" application as same as on the ordinary
CNC screen. The virtual CNC screen is equivalent to VGA display device. C Exe-
cutor application program which runs on the ordinary CNC equipment can also
run on these equipments by re-compiling and linking as it is. (Some source
codes might be modified.) Some screen display functions are restricted by
"CNC screen display" application, and some function's behaviors are different
from ordinary specifications on the true CNC.
In this section, how each task of the application program runs is described.
PC starts
|
v
CNC starts -------> Auxiliary tasks start [1]
| |
v |
"CNCscrnApp" starts ------------> Main task starts [2]
| | |
| | *---> Window task starts
| | | [3] |
v | | |
"CNCscrnApp" ends ----------------------> x - - - - - > x
| | .[4] |[5]
| | . |
v | . |
"CNCscrnApp" starts --------------------> x - - - - - > x
| | |[6] |[7]
| | | |
v | | |
"CNCscrnApp" ends ----------------------> x - - - - - > x
| | .[4] |[5]
| | . |
v v v v
[1] Auxiliary tasks start at CNC system start-up time. After started,
they run as same as on the ordinary FS30i. Because the main task and
the window task don't run until "CNCscrnApp" starts for the first
time, auxiliary tasks can't communicate with the main task or the
window task. Except this, it is not necessary for auxiliary tasks to
take care of whether CNC screen is displayed on PC or not.
(Auxiliary tasks may not exist.)
[2] The main task starts at the first time "CNCscrnApp" started. After
this, it runs as same as on the ordinary FS30i until "CNCscrnApp"
closes. Until then, the main task runs during displaying C-EXE
screen and it sleeps during displaying CNC's screen.
[3] The window task starts when "os_strt_wtsk()" function is called in
the main task. After this, the window task goes on running whether
CNC's screen is displayed or not.
(The window task may not exist.)
[4] The main task goes sleeping when "CNCscrnApp" is closed. This status
is same as the screen is changed to CNC's screen. If C-EXE appli-
cation inhibits screen changing, "CNCscrnApp" can't close itself.
The application program should sometimes enable to change the screen.
[5] The window task must close already opened VGA windows when "CNCscrn-
APP" is terminated. "CNCscrnApp" can't close itself while any VGA
windows keep opening. It is possible to test whether "CNCscrnApp" is
going closed or not by "crt_pcinfo()" function.
[6] The main task runs again when "CNCscrnApp" is re-opened. CNC's screen
is selected when "CNCscrnApp" is re-opened. (That is, the main task
is sleeping.) After then, the main task runs actually when C-EXE
screen is selected.
[7] The window task re-display VGA windows when "CNCscrnApp" is opened
again. It is possible to test whether "CNCscrnApp" is re-opened or
not by "crt_pcinfo()" function as same as [5].
(2) FS300i with HSSB/Ethernet
[1] Auxiliary tasks start at CNC system start-up time. After started,
they run as same as on the ordinary FS30i. It is not necessary for
auxiliary tasks to take care of whether CNC screen is displayed on
PC or not. (Auxiliary tasks may not exist.)
[2] The main task starts after the auxiliary tasks started. It runs as
same as on the ordinary FS30i until "CNCscrnApp" is opened on PC.
Until then, the main task runs during displaying C-EXE screen and it
sleeps during displaying CNC's screen.
In this section, differences from C Executor on the ordinary FS30i are de-
scribed. You can regard the specifications which are not listed below as
same as on the ordinary FS30i with VGA display device. The following descrip-
tions are applied to PC side screen if no special comment. They runs on
FS300i with HSSB/Ethernet as same as the ordinary FS30i.
[*] mark which is added to "unavailable ..." etc. means that no error occurs
and nothing is done even if the function is used.
(2) The screen is initialized by changing screen between CNC side and PC
side. At this time, all contents already displayed are cleared. So
the application program must redraw the screen.
(4) Overlapping method about text and graphics in 16-color graphics (in
which both text and graphics are displayed overlapping each other)
is different from the ordinary FS30i. "Composite" mode is not sup-
ported. [*] Only "Character over graphics" or "Graphics over charac-
ter" can be selected. The default mode if "Character over graphics".
(6) Automatic key repeating is always effective for key-input from both
PC's keyboard and MDI keyboard while PC side screen is alive. (It is
independent of the application program setting.) While CNC side
screen is alive on FS300i with HSSB/Ethernet, whether automatic key
repeating is effective or not depends on the application program
setting.
(7) Customizing of MDI key for CNC's screen is unavailable. [*]
"aux_mdi_putmatrix()" or "aux_mdi_altmatrix()" functions take no
effect to CNC side key matrix.
(8) It is impossible to turn ON and OFF back-light of LCD screen by
"ESC [>9l" and "ESC [>9h" while PC side screen is alive. [*]
A) Alterations
(1) An application program which runs on FS300i should not make screen
changing inhibited. For example, don't execute "crt_setswt(
CRT_SWT_DIS )" (don't inhibit screen changing actively), execute
"crt_setswt( CRT_SWT_GREN )" while it draws graphics (enable to
change screen during drawing graphics), etc.
(2) Redraw all contents in the user screen if the screen is switched
between CNC side and PC side. For example, get the current output
device, CNC or PC, using "crt_pcinfo()" function, and if it switches,
redraw whole screen.
(3) Don't execute I/O operation from/to DRIVE B: (memory card) on FS300i
with PC.
(4) The application program which uses "Composite" graphic mode doesn't
correctly draw graphics on FS300i. It is needed to redesign color
specification for application screen using "Character over graphics"
mode.
(5) Don't use 256-color graphics mode. Modify the application program
to use only 16 colors.
(6) If you want not to use automatic key repeating on PC side screen,
set delay time and interval time for key repeating both as max value
(1024[msec]) using "aux_mdi_repeat()" function.
(7) If you want to customize MDI key mapping for CNC's screen, alter key
mapping on PC side ("CNCscrnApp").
(11) The application program which runs on FS300i with PC must have an exe-
cution architecture such as it runs correctly without the main task
and the window task running. For example, ladder program of PMC or
macro program don't refer variables in which the main task sets any
value, because it is no warranty that the main task has already run
when ladder or macro program is executed. Execute initialization
processes not in the main task but in any auxiliary tasks.
(12) Basically, leave CNC screen switching control to CNC software. C-EXE
application program should not touch screen switching process.
Application building process for FS300i is same as for the ordinary FS30i.
You will follow C-EXE application building process for the ordinary FS30i.
C) Other notices
Screen refresh speed may slow down while PC side screen is alive according
to its PC's processor performance. But CNC internal process executions which
is independent of screen displaying (such as auxiliary tasks execution) run
as same speed as the ordinary FS30i.
5.8.5 Function reference
------------------------------------------------------------------------------
1. Get status of CNC screen display application <Main>
------------------------------------------------------------------------------
[Name]
crt_pcinfo
[Syntax]
#include <crt.h>
unsigned short crt_pcinfo( void ) ;
[Arguments]
------
[Return]
Returns status of CNC screen display application.
[Description]
Gets status of "CNC screen display" application program which runs
on PC of FANUC Series 300i.
The main task of C Executor runs only while CNC screen is displayed
on PC side.(in case of FS300i with PC) Auxiliary tasks and the window
task always run whether CNC screen is displayed or not. This function
is used to test if screen function is available or not in auxiliary
tasks or the window task. For example, "if CNC screen goes closed,
the window task closes VGA windows", for this case, this function is
used.
Screen switching must be enabled when "CNCscrnApp" starts up and
ends. (If screen switching is disabled, "CNCscrnApp" can't start/
end.) Call this function periodically, and enable screen switching
when CRT_PC_PWON or CRT_PC_END flag rises up.
[Example]
The following program closes VGA windows when "CNCscrnApp" goes
closed on PC. (This is executed in the window task.)
#include <crt.h>
5.9.2 Specification
Execution 8 msec
interval
(Interval time is not always fixed. Refer following
"Task execution rule".)
Type char, unsigned char, short, unsigned short, int, unsigned int,
long, unsigned long, array of these types and pointers to these
type variables.
All of the other library functions are unavailable. High-Level Task can't
call all existent library functions, for example, ANSI standard functions
such as "printf", "malloc", "strcpy", etc. or FANUC original functions
other than those above.
Refer to 34window.man for descriptions about functions other than rettask()
or cnc_hldata().
High-Level Task can share data with the other tasks via D-RAM common
variables (dramver.c) or S-RAM common variables (sramver.c).
5.9.3 Task execution rule
High-Level Task (B) is surely called once at each 8 msec. But execution
intervals are not always exact 8 msec.
(T1) <---- 8msec ---> <---- 8msec ---> <---- 8msec ---> <---- 8msec --->
|----------------|----------------|----------------|----------------|
|--->|==>| |----->|==>| |--->|==>| |--->|==>|
(T2) |<---- 9msec ----->|<--- 7msec -->|<---- 8msec --->|
The following variables (management data) are defined for looking over the
execution time of High-Level Task.
High-Level task starts on the 1st 8 msec interrupt procedure just after
completion of preparation for all tasks. This execution doesn't link to
any other tasks' start-up. Therefore, start-up order of High-Level task
and the other tasks if not fixed.
5.9.4 Application programming
for(;;) {
[Process for each 8 msec]
rettask() ; <-- This function interrupts the
} execution of High-Level Task.
}
------------------------------------------------------------------------------
1. Interrupt execution of High-Level Task <HILEV>
------------------------------------------------------------------------------
[Name]
rettask
[Syntax]
void rettask( void )
[Arguments]
------
[Return]
------
[Description]
Interrupts High-Level Task's process.
for(;;) {
[Process for each 8 msec]
rettask() ;
}
}
[Name]
cnc_hldata
[Syntax]
#include <hilev.h>
int cnc_hldata( int mode ) ;
[Arguments]
mode execution mode (DATA_START/DATA_END)
[Return]
Always 0 returns.
[Description]
The start and end of execution management data getting.
for(;;) {
cnc_hldata( DATA_START );
[Process for each 8 msec]]
cnc_hldata( DATA_END );
rettask() ;
}
}
Make sure that the desired processing is executed between cnc_hldata
calls, as shown above.
[Attention]
Please do not call this function in the case that don't get execution
management data, to economize on processing time.
3. High-Level task execution management data
"High-Level task execution management data" are variables in where how High-
Level task runs is stored. The following structure is defined.
struct HL_MNGDATA {
unsigned long HL_COUNT ;
unsigned int HL_STIME ;
unsigned int HL_ETIME ;
unsigned int HL_MAXETIME ;
unsigned int HL_MAXPROCTIME ;
unsigned int HL_TIMEOVER ;
unsigned int HL_RETFLAG ;
unsigned int HL_BUFCTRL ;
unsigned int HL_BUFSIZE ;
unsigned int HL_BUFIDX ;
unsigned long HL_PTRBUF ;
} ;
All tasks can access this "HL_MNGDATA". All members are readable and
writable.
HL_ETIME - HL_STIME
HL_MAXETIME Maximum value of HL_ETIME.
(Example)
* Character output
Use "putchar()" to display one by one.
--> Use "puts()" or "printf()" to display one character string.
* Reading/Writing NC data
To read/write the continuous data, use "range type" function other
than single access type function.
On VGA display device, characters are displayed very slowly while the
character cursor is enabled by "ESC[>5l". To avoid this, disable the cursor
by specifying "ESC[>5h" mode.
(2) How to use inter-task common variable
There are two type variables (memory) that C Executor application can access.
Program code, global variables, static variables and stack are (including
local variables) for each task are allocated in each task's local memory.
< Local memory for each task >
+-------------------------------+
| Program code |
+-------------------------------+
| Global variables, |
| Static variables |
+-------------------------------+
| Stack area (Local variables) |
+-------------------------------+
For multitask application, inter-task common variables, which are allocated
on common memory area, is used to share information with the other tasks.
There are two memory area for inter-task common variable on S-RAM and D-RAM.
The variables which are defined in "SRAMVER.C" and "DRAMVER.C" of the
application program are allocated on inter-task common memory area of S-RAM
and D-RAM.
* Keep the NC screens which are needed for maintenance work (mainly
such as [SYSTEM] screens) displayable.
The auxiliary tasks don't well respond to the events because of task
management specification. For example, in the application which has a
periodical auxiliary task execution, the actual period of the auxiliary task
may scatter by 10 - 20 [msec]. This is based on that the C application tasks
coexist with the NC software tasks and its priority is lower than the NC task.
The C application has an enough response for man-machine interface processing.
Use the PMC ladder software or the C application of PMC for processing
which needs sure response. For example, sampling machine signals or load of
motors periodically, communicating with the other devices, PMC is more
suitable for these application than C Executor.
B-63944EN-3/01 INDEX
INDEX
<Number> <H>
2-byte characters........................................................... 720 High-Level Task ........................................................... 760
How do application program run on each equipment ... 750
<A>
How to make application program.......................... 59, 748
ANSI C standard library ..................................... 18, 38, 70
Application program......................................................... 8 <I>
Application program development environment............. 14 INDEX............................................................................ 35
Application programming............................................. 764 Installing the Diab C/C++ Power-PC compiler .............. 65
Applying C Executor to machine.................................. 772
<K>
Available functions for the window task ...................... 747
Kanji character code ..................................................... 726
<C> Key operation at power on............................................ 734
C Executor ........................................................................ 6 Keycode ........................................................................ 713
C language library function list ...................................... 18 Keycode of special keys on MDI panel ........................ 714
C library............................................................................ 7
<L>
CNC/PMC window library ............................... 24, 48, 301
List of Functions............................................................. 38
Code Tables .................................................................. 713
Compatibility related to variables of type 'int' ................ 66 <M>
Composition of development system.............................. 14 MAKEFILE .................................................................... 63
Conforming CNC screen display .................................. 749 Making application program......................................... 755
Conforming O8-digits program number ....................... 744 MDI operation library................................................... 482
CRT display control characters..................................... 715 MS-C extended C standard library ......................... 21, 204
CRT operation library................................................... 507 Multitasking.................................................................. 727
<D> <N>
Dat2mem utility manual ............................................... 738 Notes...................................................................................
Data access between tasks ............................................ 729
<O>
Describing 2-byte characters in source-codes................. 66
Other libraries ........................................................... 26, 51
Development procedure.................................................. 16
Other References........................................................... 727
Difference of each task class......................................... 728
Outline ............................................................................ 59
Display code for single byte characters ........................ 723
Overview........................................................... 3, 745, 749
Display control escape sequences................................. 715
Overview of High-Level Task....................................... 760
Displayable characters .................................................. 719
<P>
<F>
Parameter setting on CNC ............................................ 735
FCA Library ................................................................. 659
Power-on procedure...................................................... 734
Feature .............................................................................. 4
Programming technique................................................ 770
File Operation Library .................................................. 604
File system.................................................................... 731 <R>
F-ROM Library............................................................. 692 Remarks .......................................................................... 67
Function reference .......................................... 68, 757, 765 Required software for application development ............. 37
Restrictions on specification......................................... 754
<G>
Graphic library.................................................. 22, 46, 207
i-1
INDEX B-63944EN-3/01
<S>
Save current environment for non-local jump.
<Main,Alarm,Comm> .................................................. 111
Serial Library................................................................ 612
Single byte characters ................................................... 719
Special files .................................................................... 62
Specification ................................................................. 760
System components .......................................................... 6
<T>
Task classes .................................................................. 727
Task execution rule....................................................... 762
Task Management......................................................... 730
Task management library.............................................. 631
Task switching.............................................................. 728
The hardwares of CNC which are used in C Executor.... 11
Touch-panel Library ..................................................... 707
<U>
Usage of the window task ............................................. 746
Using compiler libraries ................................................. 66
<V>
Various techniques ....................................................... 770
<W>
Window task................................................................. 745
Window task's execution .............................................. 745
i-2
Revision Record
FANUC Series 30i/300i/300is-MODEL A C Language Executor PROGRAMMIG MANUAL (B-63944EN-3)
01 Jul., 2003