/* * ***************************************************************** * * * * * Copyright (c) Fast Corporation, 1997 * * * * * * All Rights Reserved. Unpublished rights reserved under * * * the copyright laws of the Japan. * * * * * * The software contained on this media is proprietary to * * * and embodies the confidential technology of Fast * * * Corporation. Possession, use, duplication or * * * dissemination of the software and media is authorized only * * * pursuant to a valid written license from Fast Corporation. * * * * * ***************************************************************** */ /* CSC90X C−LINK通信サンプルプログラム */ /* メインルーチン C_L90X.C */ /*[作成者]A.Kameda */ /* 目的: C−LINKによる通信プログラム(90X側) 関数: 履歴: Ver 1.0 97/08/18 注記: PC側(C_L98.EXE,C_LAT.EXE)との通信プログラム 処理手順 90X PC @PC側よりコマンド('F')受信。 | <--- F --- | APC側へコマンド('O')送信。 | ---- O --> | BPC側よりファイル受信。 | <= file == | CPC側へコマンド('F')送信。 | ---- F --> | DPC側よりコマンド('O')受信。 | <--- O --- | EPC側へファイル送信。 | == file => | */ /* * Include compiler runtime library */ /* * Include CSC90X library */ #include "f_cnet.h" /* C−NET(C−LINK)ライブラリ */ #include "f_stdio.h" /* 標準入出力、RS232Cライブラリ */ #include "f_file.h" /* ファイルシステムライブラリ */ #include "f_graph.h" /* グラフィック表示ライブラリ */ #include "f_gui.h" /* カーソル/パッド関連ライブラリ */ #include "f_image.h" /* メモリ操作ライブラリ */ /* * Include CSC90X common local */ /* * プロトタイプ宣言 */ static int CL90X_file_recv( void ); static int CL90X_file_send( void ); /*---------------------------------------------------------------------------*/ /* メイン */ void main( void ) { int ret; int status; int dummy_x, dummy_y; Lib_init_cursor(); if( Lib_get_cursor_mode() ) Lib_erase_cursor(); Lib_chrdisp( 1, 30, "キーを押してください" ); while( 1 ) { status = Lib_see_current_position( &dummy_x, &dummy_y ); if( 0 != status ) break; } Lib_chrdisp( 1, 30, " " ); Lib_chrdisp( 1, 30, "C−LINK通信開始" ); /* C−LINKオープン */ if( NORMAL_RETURN == Lib_open_clink( SIO_CHANNEL0, NODE_8 ) ) /* 自局ノードは8 */ { /* 成功 */ /* ファイル受信 */ ret = CL90X_file_recv(); /* ファイル送信 */ if( ret ) CL90X_file_send(); /* C−LINKクローズ */ Lib_close_clink( SIO_CHANNEL0 ); } Lib_memory_clear( CHAR_PLANE ); } /* ファイル受信 */ static int CL90X_file_recv() /* [戻り値] 1 成功 0 失敗 */ { int ch; int node; int ret; ret = 0; /* コマンド(データ)の受信 */ Lib_chrdisp( 1, 1, "コマンド受信" ); if( EOF != ( ch = Lib_getc_clink( &node, SIO_CHANNEL0 ) ) ) { if( 'F' == (ch & 0xff) ) { Lib_chrdisp( 1, 1, "コマンド受信:成功" ); ret = 1; } } /* コマンド(データ)の送信 */ if( ret ) { Lib_chrdisp( 1, 2, "コマンド送信" ); if( EOF != Lib_putc_clink( 'O', NODE_0, SIO_CHANNEL0 ) ) /* 他局ノードは0 */ { Lib_chrdisp( 1, 2, "コマンド送信:成功" ); ret = 1; } else ret = 0; } /* ファイルの受信 */ if( ret ) { Lib_chrdisp( 1, 3, "ファイル受信" ); if( NORMAL_RETURN == Lib_fcopy( "\\C_LINK0\\SAMPLE.DAT", "\\FS0\\" ) ) { Lib_chrdisp( 1, 3, "ファイル受信:成功" ); ret = 1; } else ret = 0; } return ret; } /* ファイル送信 */ static int CL90X_file_send() /* [戻り値] 1 成功 0 失敗 */ { int ch; int node; int ret; ret = 0; /* コマンド(データ)の送信 */ Lib_chrdisp( 1, 4, "コマンド送信" ); if( EOF != Lib_putc_clink( 'F', NODE_0, SIO_CHANNEL0 ) ) /* 他局ノードは0 */ { Lib_chrdisp( 1, 4, "コマンド送信:成功" ); ret = 1; } /* コマンド(データ)の受信 */ if( ret ) { Lib_chrdisp( 1, 5, "コマンド受信" ); if( EOF != ( ch = Lib_getc_clink( &node, SIO_CHANNEL0 ) ) ) { if( 'O' == (ch & 0xff) ) { Lib_chrdisp( 1, 5, "コマンド受信:成功" ); ret = 1; } else ret = 0; } else ret = 0; } /* ファイルの送信 */ if( ret ) { Lib_chrdisp( 1, 6, "ファイル送信" ); if( NORMAL_RETURN == Lib_fcopy( "\\FS0\\SAMPLE.DAT", "\\C_LINK0\\" ) ) { Lib_chrdisp( 1, 6, "ファイル送信:成功" ); ret = 1; } else ret = 0; } return ret; } /*---------------------------------------------------------------------------*/