/* * ***************************************************************** * * * * * 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 RS232C通信サンプルプログラム */ /* メインルーチン C_R90X.C */ /*[作成者]A.Kameda */ /* 目的: RS232Cによる通信プログラム(90X側) 関数: 履歴: Ver 1.0 97/08/18 注記: PC側(C_R98.EXE,C_RAT.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_stdio.h" /* 標準入出力、RS232Cライブラリ */ #include "f_file.h" /* ファイルシステムライブラリ */ #include "f_graph.h" /* グラフィック表示ライブラリ */ #include "f_gui.h" /* カーソル/パッド関連ライブラリ */ #include "f_image.h" /* メモリ操作ライブラリ */ #include "f_pinf.h" /* システムパラメータ更新/参照ライブラリ */ /* * Include CSC90X common local */ /* * プロトタイプ宣言 */ static int CR90X_file_recv( void ); static int CR90X_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, "RS232C通信開始" ); /* RS232Cオープン */ if( NORMAL_RETURN == Lib_opensio( SIO_CHANNEL0 ) ) { /* 成功 */ if( NORMAL_RETURN == Lib_speed( SIO_CHANNEL0, RATE9600BPS, DATA_BIT_8, STOP_BIT_1, NONE, FLOW_NONE ) ) { /* ファイル受信 */ ret = CR90X_file_recv(); /* ファイル送信 */ if( ret ) CR90X_file_send(); } /* RS232Cクローズ */ Lib_clossio( SIO_CHANNEL0 ); } Lib_memory_clear( CHAR_PLANE ); } /* ファイル受信 */ static int CR90X_file_recv() /* [戻り値] 1 成功 0 失敗 */ { int ch; int ret; ret = 0; /* コマンド(データ)の受信 */ Lib_chrdisp( 1, 1, "コマンド受信" ); if( EOF != ( ch = Lib_getc_rs232c( SIO_CHANNEL0 ) ) ) { if( 'F' == (ch & 0xff) ) { Lib_chrdisp( 1, 1, "コマンド受信:成功" ); ret = 1; } } /* コマンド(データ)の送信 */ if( ret ) { Lib_chrdisp( 1, 2, "コマンド送信" ); if( EOF != Lib_putc_rs232c( 'O', SIO_CHANNEL0 ) ) { Lib_chrdisp( 1, 2, "コマンド送信:成功" ); ret = 1; } else ret = 0; } /* ファイルの受信 */ if( ret ) { Lib_chrdisp( 1, 3, "ファイル受信" ); if( NORMAL_RETURN == Lib_fcopy( "\\RS232C0\\SAMPLE.DAT", "\\FS0\\" ) ) { Lib_chrdisp( 1, 3, "ファイル受信:成功" ); ret = 1; } else ret = 0; } return ret; } /* ファイル送信 */ static int CR90X_file_send() /* [戻り値] 1 成功 0 失敗 */ { int ch; int ret; ret = 0; /* コマンド(データ)の送信 */ Lib_chrdisp( 1, 4, "コマンド送信" ); if( EOF != Lib_putc_rs232c( 'F', SIO_CHANNEL0 ) ) { Lib_chrdisp( 1, 4, "コマンド送信:成功" ); ret = 1; } /* コマンド(データ)の受信 */ if( ret ) { Lib_chrdisp( 1, 5, "コマンド受信" ); if( EOF != ( ch = Lib_getc_rs232c( 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", "\\RS232C0\\" ) ) { Lib_chrdisp( 1, 6, "ファイル送信:成功" ); ret = 1; } else ret = 0; } return ret; } /*---------------------------------------------------------------------------*/