⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serial.txt

📁 FANUC数控设备的采集开发包FOCAS2.针对串口内容.
💻 TXT
📖 第 1 页 / 共 3 页
字号:

                               SERIAL.TXT  File
               README file for Serial/FCA Communication Library
           (C) Copyright FANUC LTD, 1996-2007, All Rights Reserved.


This document provides the information about Serial/FCA Communication Library.
Please read this before using the software.

------------------------------------------------------------------------------
[1] Summary
[3] Notes
[4] Function List
[5] Function Specification
------------------------------------------------------------------------------

  Microsoft, Windows, Visual Basic are registered trademarks of Microsoft 
  corporation, U.S.A.


==============================================================================
[1] Summary
==============================================================================

The Serial/FCA Communication Library is a library for the use of external 
serial devices via serial ports of PC, and consists of the Serial Library 
and the FCA Library.

The Serial Library is a general-purpose library for the use of off-the-shelf 
serial devices. The FCA Library is an exclusive library for the use of FCA 
(FANUC CASSETTE ADAPTER) devices.

This Library can be used from the 32-bit development language.
(Visual C++ 2.x/4.x, Visual Basic 4.x)


==============================================================================
[2] Notes
==============================================================================

* Using the library in a multithreaded environment

  There are some limitations of using this library in a multithreaded 
  environment. For the Serial Library, a process can access to multiple ports 
  at the same time, but multiple threads cannot access to a port at the same 
  time. For the FCA Library, a process cannot access to multiple ports at the 
  same time.

* Header file

  Functions of this library have been made by using specifications of 
  "dllexport". To call the functions from C/C++ language, specifications of 
  "dllimport" are necessary. Because these specifications are described in 
  the header file FCA32.H, please include this header file.

* Using the library from Visual Basic

  Declarations of functions and definitions of constant values that are 
  necessary to use this library from Visual Basic, are described in 
  FCA32.BAS. Please add this file to a project of Visual Basic.
  
  Please note the followings.
      + Names of members of user-defined types defined in FCA32.BAS are 
        different from names of members of structures defined in FCA32.H.
      + Type int (32-bit) of Visual C++ corresponds to type Long of Visual 
        Basic.
      + Type char of Visual C++ corresponds to type Byte of Visual Basic, but 
        type String is used for the following functions.
          rs_open, fca_open, fca_fopen, fca_rename, fca_delete

* Treatment for an alarm state of the FCA device

  Even if functions of the FCA Library succeed, the FCA device may become in 
  an alarm state afterwards. When the FCA device is in an alarm state, 
  functions of the FCA Library except the fca_status function return nonzero 
  value.
  
  If functions of the FCA Library return nonzero value, it is expected that 
  the FCA device is in an alarm state. You can know whether the FCA device is 
  in an alarm state by examining whether the DR signal is off. Please examine 
  the status of the DR signal by calling the rs_status function of the Serial 
  Library.
  
  When the FCA device is in an alarm state, it is necessary to reset the FCA 
  device. Please reset the FCA device by calling the fca_status function.
  
  If the fca_status function is called after a file on the FCA device is 
  opened, the input/output operation to the file cannot be continued. To 
  resume the input/output operation, close the file once, and open the file 
  again.

* Limitation of serial ports

  Serial ports that are available for this library, are limited to COM1 and 
  COM2.


==============================================================================
[3] Function List
==============================================================================

[Serial Library]
  ----------------------------------------------------------------------------
  Function Name   Brief Description
  ----------------------------------------------------------------------------
  rs_open         Initializes the communication line.
  rs_close        Terminates the communication line.
  rs_putc         Outputs 1 byte to the transmission buffer.
  rs_getc         Inputs 1 byte from the reception buffer.
  rs_write        Outputs multiple bytes to the transmission buffer.
  rs_read         Inputs multiple bytes from the reception buffer.
  rs_buffer       Examines and operates the communication buffer.
  rs_status       Gets the status of the communication line and buffer.
  ----------------------------------------------------------------------------

[FCA Library]
  ----------------------------------------------------------------------------
  Function Name   Brief Description
  ----------------------------------------------------------------------------
  fca_setparam    Initializes the communication line and begins the 
                  communication with the FCA device.
  fca_bye         Terminates the communication with the FCA device and frees 
                  the communication line.
  fca_open        Opens a binary file on the FCA device.
  fca_close       Closes the file opened by the fca_open function.
  fca_read        Reads data from the file opened by the fca_open function.
  fca_write       Writes data to the file opened by the fca_open function.
  fca_fopen       Opens an ASCII file on the FCA device.
  fca_fclose      Closes the file opened by the fca_fopen function.
  fca_getc        Reads a character from the file opened by the fca_fopen 
                  function.
  fca_putc        Writes a character to the file opened by the fca_fopen 
                  function.
  fca_delete      Deletes a file on the FCA device.
  fca_rename      Changes a file name on the FCA device.
  fca_readdir     Reads the directory information on the FCA device.
  fca_status      Reads the status information on the FCA device.
  fca_remains     Reads the rest of the floppy disk on the FCA device.
  ----------------------------------------------------------------------------


==============================================================================
[4] Function Specification
==============================================================================


Function Name:
    rs_open

Description:
    Initializes the communication line.

Declaration:
    #include "fca32.h"
    int WINAPI rs_open(int port, ser_t *param, char *mode);

Arguments:
    port
        Specifies the serial port number.
            1: COM1
            2: COM2
    
    param
        Points to a ser_t structure that is necessary for initialization of 
        the communication line.
        If NULL is specified, the default setting is used.
    
    mode
        Points to a null-terminated string that specifies the communication 
        mode.
            "r" : Reception mode
            "w" : Transmission mode
            "rw": Reception and Transmission mode

Return Values:
    If the function succeeds, the return value is 0.
    If an error occurs, the return value is nonzero value.

Remarks:
    The ser_t structure contains parameters used for initialization of the 
    communication line.
    
        typedef struct PortDefUser {
            int baud;
            int stop_bit;
            int parity;
            int data_bit;
            int hardflow;
            int dc_enable;
            int dc_put;
            int dc1_code;
            int dc2_code;
            int dc3_code;
            int dc4_code;
        } ser_t;
        
        Member      Description
        ----------------------------------------------------------------------
        baud        Specifies the baud rate.
                        FCA_BAUD_1200 :  1200 baud
                        FCA_BAUD_2400 :  2400 baud
                        FCA_BAUD_4800 :  4800 baud
                        FCA_BAUD_9600 :  9600 baud
                        FCA_BAUD_19200: 19200 baud
        
        stop_bit    Specifies the stop bits.
                        STOP_1: 1 stop bit
                        STOP_2: 2 stop bits
        
        parity      Specifies the parity bit.
                        PARITY_N: No parity
                        PARITY_E: Even parity
                        PARITY_O: Odd parity
        
        data_bit    Specifies the character size.
                        DATA_7: 7 bits
                        DATA_8: 8 bits
        
        hardflow    Specifies the flow control by the hardware signal (CS/RS).
                        0: No control
                        1: Both Transmission and Reception
                        2: Transmission only
                        3: Reception only
        
        dc_enable   Specifies the flow control by the DC code.
                        0: No control
                        1: Both Transmission and Reception
                        2: Transmission only
                        3: Reception only
        
        dc_put      Specifies whether the DC code is output on opening/
                    closing the port.
                        0: Not output
                        1: output
                    
                    The relations between the output DC code and the 
                    communication mode are as follows.
                    
                            Mode        Opening   Closing
                        ----------------------------------
                        Reception        DC1       DC3
                        Transmission     DC2       DC4
                        Transmission
                         and Reception   None      None
        
        dc1_code    Specifies the DC1 code.
                    In general, specify 0x11.
        
        dc2_code    Specifies the DC2 code.
                    In general, specify 0x12.
        
        dc3_code    Specifies the DC3 code.
                    In general, specify 0x13. To keep compatibility with CNC, 
                    specify 0x93.
        
        dc4_code    Specifies the DC4 code.
                    In general, specify 0x14.
------------------------------------------------------------------------------


Function Name:
    rs_close

Description:
    Terminates the communication line.

Declaration:
    #include "fca32.h"
    int WINAPI rs_close(int port);

Arguments:
    port
        Specifies the serial port number.
            1: COM1
            2: COM2

Return Values:
    If the function succeeds, the return value is 0.
    If an error occurs, the return value is nonzero value.

Remarks:
    If the DC code is specified to output on closing the port by the rs_open 
    function, the DC code is output.
    
    The rs_close function clears the transmission and reception buffer.
    If the rs_close function is called just after the transmission operation 
    by the rs_putc function or the rs_write function, there is a danger of 
    failure in the transmission of the expected data.
    To avoid this, confirm that the transmission buffer is empty by the 
    rs_buffer function, and call the rs_close function.
------------------------------------------------------------------------------


Function Name:
    rs_putc

Description:
    Outputs 1 byte to the transmission buffer.

Declaration:
    #include "fca32.h"
    int WINAPI rs_putc(int c, int port);

Arguments:
    c
        Specifies the data to be output.
    
    port
        Specifies the serial port number.
            1: COM1
            2: COM2

Return Values:
    If the function succeeds, the return value is 1.
    If the function cannot output the data because the transmission buffer is 
    full, the return value is 0.
    If an error occurs, the return value is -1.

Remarks:
    The rs_putc function outputs the data to the transmission buffer.
    To know that the data is actually sent, confirm that the transmission 
    buffer is empty by the rs_buffer function.
------------------------------------------------------------------------------


Function Name:
    rs_getc

Description:
    Inputs 1 byte from the reception buffer.

Declaration:
    #include "fca32.h"
    int WINAPI rs_getc(int port);

Arguments:
    port
        Specifies the serial port number.
            1: COM1
            2: COM2

Return Values:
    If the function succeeds, the return value is the received data.
    If the reception buffer has no data or an error occurs, the return value 
    is -1.
------------------------------------------------------------------------------


Function Name:
    rs_write

Description:
    Outputs multiple bytes to the transmission buffer.

Declaration:
    #include "fca32.h"
    int WINAPI rs_write(char *buffer, int size, int port);

Arguments:
    buffer
        Points to a buffer containing the data to be output.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -