2011年1月17日(月) 21:57
----------------------ここから----------------------
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <malloc.h>
#include "kuro_rs.h"
#include "kuro_rs_common.h"
int main(int argc,char *argv[])
{
unsigned char buf[255];
char *data_file = NULL;
char *device = "/dev/ttyUSB0";
FILE *fp;
RS *rp;
if( argc >= 2 && argv[1] && *argv[1] )
data_file = argv[1];
if( !data_file ) {
printf("%s data file\n", argv[0]);
exit(1);
}
if( !(rp = open_rs(device, 1)) ) {
printf("device open error(%s)\n", device);
exit(1);
}
if( recive_irdata(rp, buf) ) {
printf("recive error\n");
exit(1);
}
close_rs(rp);
if( !(fp = fopen(data_file, "wb")) ) {
printf("file open err(%s)\n", data_file);
exit(1);
} else {
fwrite(buf, sizeof(unsigned char), REC_DATA_SIZE, fp);
fclose(fp);
}
printf("Rec File : %s\n", data_file);
exit(0);
}
----------------------ここまで----------------------
----------------------ここから----------------------
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <malloc.h>
#include "kuro_rs.h"
#include "kuro_rs_common.h"
int main(int argc,char *argv[])
{
unsigned char buf[255];
char *port = "1";
char *data_file = NULL;
char *device = "/dev/ttyUSB0";
FILE *fp;
RS *rp;
if( argc >= 2 && argv[1] && *argv[1] )
data_file = argv[1];
if( argc >= 3 && argv[1] && *argv[2] )
port = argv[2];
if( !data_file ) {
printf("%s data file [port]\n", argv[0]);
exit(1);
}
if( !(fp = fopen(data_file, "rb")) ) {
printf("file open err(%s)\n", data_file);
exit(1);
} else {
fread(buf, sizeof(unsigned char), REC_DATA_SIZE, fp);
fclose(fp);
}
if( !port || (*port < '1' || *port > '4') )
*port = '1';
if( !(rp = open_rs(device, 1)) ) {
printf("device open error(%s)\n", device);
exit(1);
}
if( send_irdata(rp, *port, buf) ) {
printf("can't send data\n");
exit(1);
}
close_rs(rp);
printf("Send File : %s\n", data_file);
exit(0);
}
----------------------ここまで----------------------
written by sirius [KURO-RS] [この記事のURL] [コメントを書く] [コメント(0)] [TB(0)]
MySketch 2.7.2 written by 夕雨