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

📄 serial.txt

📁 FANUC数控设备的采集开发包FOCAS2.针对串口内容.
💻 TXT
📖 第 1 页 / 共 3 页
字号:
    
    size
        Specifies the size of 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 the size of the output data.
    If the transmission buffer does not have sufficient room of the specified 
    size, the return value is smaller than the specified size.
    If an error occurs, the return value is -1.

Remarks:
    The rs_write 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_read

Description:
    Inputs multiple bytes from the reception buffer.

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

Arguments:
    buffer
        Points to a buffer that receives the input data.
    
    size
        Specifies the size of the data to be input.
    
    port
        Specifies the serial port number.
            1: COM1
            2: COM2

Return Values:
    If the function succeeds, the return value is the size of the input data.
    If the reception buffer does not have sufficient data of the specified 
    size, the return value is smaller than the specified size.
    If an error occurs, the return value is -1.
------------------------------------------------------------------------------


Function Name:
    rs_buffer

Description:
    Examines and operates the communication buffer.

Declaration:
    #include "fca32.h"
    int WINAPI rs_buffer(int port, int cmnd);

Arguments:
    port
        Specifies the serial port number.
            1: COM1
            2: COM2
    
    cmnd
        Specifies the command to the buffer.
            RS_GET_BUF_R: Returns the size of the reception buffer.
            RS_GET_BUF_W: Returns the size of the transmission buffer.
            RS_CHK_BUF_R: Returns the number of bytes of the data in the 
                          reception buffer.
            RS_CHK_BUF_W: Returns the number of bytes of the data in the 
                          transmission buffer.
            RS_CLR_BUF_R: Clears the reception buffer.
            RS_CLR_BUF_W: Clears the transmission buffer.

Return Values:
    If the function succeeds, the return value for each command is as follows.
    
        Command         Return Value
        ----------------------------------------------------------------------
        RS_GET_BUF_R    The size of the reception buffer
        RS_GET_BUF_W    The size of the transmission buffer
        RS_CHK_BUF_R    The number of bytes of the data in the reception 
                        buffer
        RS_CHK_BUF_W    The number of bytes of the data in the transmission 
                        buffer
        RS_CLR_BUF_R    0
        RS_CLR_BUF_W    0
    
    If an error occurs, the return value is -1.
------------------------------------------------------------------------------


Function Name:
    rs_status

Description:
    Gets the status of the communication line and buffer.

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

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

Return Values:
    If the function succeeds, the return value is the status of the 
    communication line (LSI) and the status of the communication buffer as a 
    combination of the following values.

        Value           Meaning
        ----------------------------------------------------------------------
        STS_S_STOP      Stop state         (Transmission)
        STS_BUF_FULL    Buffer full        (Transmission)
        STS_R_STOP      Stop state         (Reception)
        STS_EMPTY       Buffer empty       (Reception)
        STS_OVERFLOW    Buffer overrun     (Reception)
        STS_DR_ON       DR on              (LSI)
        STS_FRAME       Framing error      (LSI)
        STS_OVERRUN     Overrun            (LSI)
        STS_PARITY      Parity error       (LSI)
        STS_CD_ON       CD on              (LSI)
    
    If an error occurs, the return value is -1.
------------------------------------------------------------------------------


Function Name:
    fca_setparam

Description:
    Initializes the communication line and begins the communication with the 
    FCA device.

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

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.

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

Remarks:
    The fca_setparam function initializes the communication line and turns on 
    the RS/ER signal.
    
    For an information about parameters to be set in the ser_t structure, 
    please refer to the explanation of the rs_open function.
    
    For the communication with the protocol B, the following setting is 
    recommended.
    
        param->baud      = FCA_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;
------------------------------------------------------------------------------


Function Name:
    fca_bye

Description:
    Terminates the communication with the FCA device and frees the 
    communication line.

Declaration:
    #include "fca32.h"
    int WINAPI fca_bye(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:
    The fca_bye function turns off the RS/ER signal and frees the 
    communication line.
    
    In the following cases, call the fca_bye function.
    
        1) When the FCA device is detached from the line.
        2) When the FCA device cannot be recovered from the error state.
        3) When the Serial Library functions (rs_xxxxxx) are used.
------------------------------------------------------------------------------


Function Name:
    fca_open

Description:
    Opens a binary file on the FCA device.

Declaration:
    #include "fca32.h"
    int WINAPI fca_open(char *name, int mode);

Arguments:
    name
        Points to a null-terminated string that specifies the file name.
        (17 characters or less)
        If the first character is "#", it is supposed that the file number is 
        specified.
            "#xxxx": The xxxx-th file (xxxx are 4 digits or less)
            "#0"   : The first file
            "#N"   : The next file
            "#E"   : The next file of the last (a new file is created)
    
    mode
        Specifies the access mode.
            0: read
            1: write

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

Remarks:
    The fca_open function should be used with the fca_close function in pairs.
    Between the fca_open function and the fca_close function, only the 
    fca_read function and the fca_write function can be called.
    If the other FCA Library functions (fca_xxxxxx) are called, an error 
    occurs. (except the fca_status function and the fca_bye function)
------------------------------------------------------------------------------


Function Name:
    fca_close

Description:
    Closes the file opened by the fca_open function.

Declaration:
    #include "fca32.h"
    int WINAPI fca_close(void);

Arguments:
    None

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

Remarks:
    The fca_close function should be used with the fca_open function in pairs.
    Between the fca_open function and the fca_close function, only the 
    fca_read function and the fca_write function can be called.
    If the other FCA Library functions (fca_xxxxxx) are called, an error 
    occurred. (except the fca_status function and the fca_bye function)
------------------------------------------------------------------------------


Function Name:
    fca_read

Description:
    Reads data from the file opened by the fca_open function.

Declaration:
    #include "fca32.h"
    int WINAPI fca_read(char *buffer, int bytes);

Arguments:
    buffer
        Points to a buffer that receives the data to be input.
    
    bytes
        Specifies the number of bytes of the data to be input.
        (65534 bytes or less)

Return Values:
    If the function succeeds, the return value is the number of bytes of the 
    input data.
    If an error occurs, the return value is -1.

Remarks:
    Because the FCA device cannot write the data of less number of bytes than 
    its input/output unit, some extra nulls might be added to the end of the 
    input data.
    If the return value is smaller than the specified number of bytes, 
    interpret that the function reaches the end of file.
    
    For a floppy disk of the FANUC format, more extra 0xFF might be added to 
    the end of the input data because the file size cannot be known correctly.
    So it is necessary to judge the end of file by an application.
------------------------------------------------------------------------------


Function Name:
    fca_write

Description:
    Writes data to the file opened by the fca_open function.

Declaration:
    #include "fca32.h"
    int WINAPI fca_write(char *buffer, int bytes);

Arguments:
    buffer
        Points to a buffer containing the data to be output.
    
    bytes
        Specifies the number of bytes of the data to be output.
        (65534 bytes or less)

Return Values:
    If the function succeeds, the return value is the number of bytes of the 
    output data.
    If an error occurs, the return value is -1.

Remarks:
    Because the FCA device cannot write the data of less number of bytes than 
    its input/output unit, some nulls are actually output for supplements of 
    its input/output unit.
    As a result, some extra nulls might be added to the end of the file on 
    the FCA device.
------------------------------------------------------------------------------


Function Name:
    fca_fopen

Description:
    Opens an ASCII file on the FCA device.

Declaration:
    #include "fca32.h"
    int WINAPI fca_fopen(char *name, char *mode);

⌨️ 快捷键说明

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