分类: 嵌入式
2017-02-14 11:39:06
系统平台:ubuntu 15.10
下载ckermit源码
下载链接:
点击“Source Code in tar, zip, or other archive formats or as separate files: CLICK HERE. ”的CLICK HERE,跳转到下载页面。
点击下载cku302.tar.gz源码包。
编译ckermit源码
先解压源码
tar zxvf cku302.tar.gz
编译
make linux
如果出现以下错误:
ckufio.o:在函数‘zvpass’中:
ckufio.c:(.text+0xbb81):对‘crypt’未定义的引用
ckcnet.o:在函数‘locate_srv_dns’中:
ckcnet.c:(.text+0x40b5):对‘__res_search’未定义的引用
ckcnet.c:(.text+0x4110):对‘__dn_expand’未定义的引用
ckcnet.c:(.text+0x4177):对‘__dn_expand’未定义的引用
ckcnet.c:(.text+0x4257):对‘__dn_expand’未定义的引用
ckcnet.o:在函数‘locate_txt_rr’中:
ckcnet.c:(.text+0xb1b4):对‘__res_search’未定义的引用
ckcnet.c:(.text+0xb20e):对‘__dn_expand’未定义的引用
ckcnet.c:(.text+0xb251):对‘__dn_expand’未定义的引用
collect2: error: ld returned 1 exit status
makefile:1202: recipe for target 'xermit' failed
make[2]: *** [xermit] Error 1
make[2]: Leaving directory '/opt/kermit'
makefile:5445: recipe for target 'linuxa' failed
make[1]: *** [linuxa] Error 2
make[1]: Leaving directory '/opt/kermit'
makefile:5473: recipe for target 'linux' failed
make: *** [linux] Error 2
解决方法是用vim 打开 makefile找到规则linuxa
linuxa:
@echo 'Making C-Kermit $(CKVER) for Linux 1.2 or later...'
@echo 'IMPORTANT: Read the comments in the linux section of the'
@echo 'makefile if you have trouble.'
$(MAKE) xermit KTARGET=$${KTARGET:-$(@)} "CC = gcc" "CC2 = gcc" \
"CFLAGS = -O -DLINUX -pipe -funsigned-char -DFNFLOAT -DCK_POSIX_SIG \
-DCK_NEWTERM -DTCPSOCKET -DLINUXFSSTND -DNOCOTFMC -DPOSIX \
-DUSE_STRERROR $(KFLAGS)" "LNKFLAGS = $(LNKFLAGS)" "LIBS = $(LIBS) -lm"
在最后一行 “-lm “后边加上 空格 -lcrypt -lresolv
再编译一次
make linux
编译完成。
生成的wermit就是了,一般情况下把它拷贝到/usr/local/bin下并重命名为kermit。
配置ckermit
在自己的家目录下创建文件 .kermit
vim ~/.kermrc
加入以下内容:
set line /dev/ttyUSB0 //根据实际情况改成自己的串口设备
set speed 115200
set carrier-watch off
set handshake none
set flow-control none
robust
set file type bin
set file name lit
set rec pack 1000
set send pack 1000
set window 5
启动kermit
直接在命令行中输入kermit回车
如果输出以下信息:
/dev/ttyUSB0: Permission denied
?SET SPEED has no effect without prior SET LINE
C-Kermit 8.0.211, 10 Apr 2004, for Linux
Copyright (C) 1985, 2004,
Trustees of Columbia University in the City of New York.
Type ? or HELP for help.
(/opt/kermit/) C-Kermit>q
需要将设备文件的权限修改一下(每次插入设备都要重新修改权限)
sudo chmod 777 /dev/ttyUSB0
再次启动输出:
C-Kermit 8.0.211, 10 Apr 2004, for Linux
Copyright (C) 1985, 2004,
Trustees of Columbia University in the City of New York.
Type ? or HELP for help.
(/opt/kermit/) C-Kermit>
就可以用了,再C-Kermit>输入c就连接上了串口:
u@u-pc:/opt/kermit$ kermit
C-Kermit 8.0.211, 10 Apr 2004, for Linux
Copyright (C) 1985, 2004,
Trustees of Columbia University in the City of New York.
Type ? or HELP for help.
(/opt/kermit/) C-Kermit>c
Connecting to /dev/ttyUSB0, speed 115200
Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
----------------------------------------------------
OK
要断开串口连接 同时按下键盘ctrl+\键,松开后再按下c键。
目前是能显示接收的字符,但是如何显示接收到的十六进制数呢?
没找到显示十六进制的方法,通过ascii中 0x41对应字符A 0x42对应字符B,输出0x41接收的是字符A,来验证串口发送的正确性。