1 Star 0 Fork 1

Yitong/ymodem-1

forked from uqifgjij/ymodem-1 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
uart.c 1.79 KB
一键复制 编辑 原始数据 按行查看 历史
Jiadakong1 提交于 2017-07-20 13:56 +08:00 . ymodem协议测试
#include "Ymodem.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
extern FILE *pFile;
void uart_start(){
pFile = fopen ( "/dev/ttyPS0" , "r+") ;
}
void uart_end(){
fclose(pFile);
printf("uart close right!\n");
}
char __getchar(){
char ch = '0';
// fread(&ch, sizeof(char), sizeof(char) , pFile );
fgetc(pFile);
//printf("%c ", ch);
return ch;
}
void __getbuf(char* buf, size_t len){
//fread(buf, sizeof(char), len, pFile );
//len = read(pFile,buf, len);
len = fread(buf, sizeof(char), len , pFile );
printf("getbuf: len=%d\n", len);
}
void __putchar( char ch ){
char ch1 = ch;
int len =0;
len = fread(&ch1, sizeof(char), sizeof(char) , pFile );;
printf("putchar: len = %d\n", len);
}
void __putbuf( char* buf, size_t len ){
}
// #include "Ymodem.h"
// #include <sys/types.h>
// #include <sys/stat.h>
// #include <fcntl.h>
//
// extern int pFile;
//
//
//
// void uart_start(){
// pFile = open ( "/dev/ttyPS0" , O_RDWR) ;
//
// }
//
// void uart_end(){
// close(pFile);
// printf("uart close right!\n");
//
// }
//
//
//
// char __getchar(){
// char ch = '0';
// read(pFile, &ch, sizeof(char));
// flush;
// sync;
// //printf("%c ", ch);
// return ch;
// }
//
// void __getbuf(char* buf, size_t len){
// //fread(buf, sizeof(char), len, pFile );
// //len = read(pFile,buf, len);
// int i = 0;
// for(i = 0; i < len; i++){
// //printf("%d:", i);
// buf[i] = __getchar();
// }
// //printf("getbuf: len=%d\n", len);
// }
//
//
// void __putchar( char ch ){
// char ch1 = ch;
// int len =0;
// len = write(pFile, &ch1, sizeof(char));
// //write(&ch1, sizeof(char), sizeof(char) , pFile );
// printf("putchar: len = %d\n", len);
// }
//
//
// void __putbuf( char* buf, size_t len ){
//
// }
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yitonge/ymodem-1.git
git@gitee.com:yitonge/ymodem-1.git
yitonge
ymodem-1
ymodem-1
master

搜索帮助