之前认真学习过三类传真机收发传真过程,也认真分析了mgetty-1.1.36与远端传真机建立连接的源码.参考其中的代码,写了个发送传真的程序。可是到phase C,modem给远端传真机发送TCF帧后,总不能接受到信号。后来找到了efax这个开源传真软件,efax比mgetty更小巧,使用起来也比较灵活。下面是在ARM9+linux2.6.12上使用我们的modem来发传真的过程。
1, 交叉编译efax,这个过程非常简单:
源代码下载地址:
这里有他的pdf使用说明文档: http://www.cce.com/efax/documentation/
解压缩下载源代码包: #tar -xzf efax-0.9.tar.gz -C /usr/local/src
修改Makefile:
CC=arm-linux-uclibc-gcc
STRIP=arm-linux-uclibc-strip
并将strip efax 改为 $(STRIP) efax
#make
make之后会生成两个文件,efax和efix. 其中efax是用来收发传真的代码,而efix是将我们的普通文件转换成相应的传真文件。源码包里的fax文件是一个shell脚本,主要在这个shell脚本里完成一些传真配置。
2,修改fax这个shell脚本:
< FAX=/tmp/fax //这里指定fax, efax, efix的path,注意该目录需可写,因为他要写log.当然可以修改源码
< EFAX=/tmp/efax
< EFIX=/tmp/efix
---
> FAX=fax
> EFAX=efax
> EFIX=efix
31c31
< DEV=ttyS4 //这里指定我的modem所在的设备名,我的modem比较多,用的是ttyS4
---
> DEV=cua1
3, 发传真,其中test是我要发的文件,628是传真号码。(我们内部电话只需要拨分机号就OK了)
>: ./fax send -l -v 628 test
./fax: ./fax: 1038: make: not found
test is text...
/tmp/efax: 29:10 efax v 0.9 Copyright 1999 Ed Casas
efax: 29:10 TIFF version 4.2 file (little-endian)
efax: 29:10 TIFF directory at 8 with 17 tags, last image.
efax: 29:10 page 1 : test.001 + 234 : 1728x1078 @ 0x0 dpi TIFF/FAX
efax: 29:10 argv[0]=/tmp/efax
efax: 29:10 argv[1]=-v
efax: 29:10 argv[2]=chewmainrxtf
efax: 29:10 argv[3]=-v
efax: 29:10 argv[4]=chewmainrxtf
efax: 29:10 argv[5]=-d/dev/ttyS4
efax: 29:10 argv[6]=-x
efax: 29:10 argv[7]=/var/lock/LCK..ttyS4
efax: 29:10 argv[8]=-iZ
efax: 29:10 argv[9]=-i&FE&D2S7=120
efax: 29:10 argv[10]=-i&C0
efax: 29:10 argv[11]=-iM1L0
efax: 29:10 argv[12]=-l
efax: 29:10 argv[13]=+1 800 555 5555
efax: 29:10 argv[14]=-kZ
efax: 29:10 argv[15]=-h
efax: 29:10 argv[16]=1927/09/19 04:29 +1 800 555 5555 Put Your Name Here p. %d/%d
efax: 29:10 argv[17]=-t
efax: 29:10 argv[18]=T628
efax: 29:10 argv[19]=test.001
efax: 29:10 created text lock file /var/lock/LCK..ttyS4
efax: 29:10 opened /dev/ttyS4
efax: 29:10 ======================= command "ATQ0V1" +++++++++++++++++++++
efax: 29:10 waiting 2 s
efax: 29:10 .592 [ATQ0V1]
efax: 29:10 .632 [OK]
efax: 29:10 response "OK"
efax: 29:10 ======================= command "ATZ" +++++++++++++++++++++
efax: 29:10 waiting 5 s
efax: 29:10 .742 [ATZ]
efax: 29:10 .802 [OK]
efax: 29:10 response "OK"
efax: 29:10 ======================= command "AT&FE&D2S7=120" +++++++++++++++++++++
efax: 29:10 waiting 5 s
efax: 29:10 .912 [AT&FE&D2S7=120]
efax: 29:10 .952 [OK]
efax: 29:10 response "OK"
efax: 29:11 ======================= command "AT&C0" +++++++++++++++++++++
efax: 29:11 waiting 5 s
efax: 29:11 .092 [OK]
efax: 29:11 response "OK"
efax: 29:11 ======================= command "ATM1L0" +++++++++++++++++++++
efax: 29:11 waiting 5 s
efax: 29:11 .242 [OK]
efax: 29:11 response "OK"
efax: 29:11 ======================= command "ATE0" +++++++++++++++++++++
efax: 29:11 waiting 5 s
efax: 29:11 .392 [OK]
efax: 29:11 response "OK"
efax: 29:11 ======================= command "ATI3" +++++++++++++++++++++
efax: 29:11 waiting 5 s
efax: 29:11 .542 [CX93001-EIS_V0.2002-V92]
efax: 29:11 .563 [OK]
efax: 29:11 response "OK"
efax: 29:11 ======================= command "AT+FCLASS=?" +++++++++++++++++++++
efax: 29:11 waiting 5 s
efax: 29:11 .713 [0,1,1.0,8]
efax: 29:11 .714 [OK]
efax: 29:11 response "OK"
efax: 29:11 ======================= command "AT+FCLASS=1" +++++++++++++++++++++
efax: 29:11 waiting 5 s
efax: 29:11 .873 [OK]
efax: 29:11 response "OK"
efax: 29:11 using CX93001-EIS_V0.2002-V92 in class 1
efax: 29:11 ======================= command "AT+FTM=?" +++++++++++++++++++++
efax: 29:11 waiting 5 s
efax: 29:11 .983 [3,24,48,72,73,74,96,97,98,121,122,145,146]
efax: 29:12 .013 [OK]
efax: 29:12 response "OK"
efax: 29:12 dialing T628
efax: 29:12 ======================= command "ATDT628" +++++++++++++++++++++
efax: 29:12 waiting 120 s
efax: 29:23 .084 [CONNECT]
efax: 29:23 response "CONNECT"
efax: 29:23 connected
efax: 29:25 waiting 2 s
efax: 29:25 .426 [OK]
efax: 29:25 response "OK"
efax: 29:25 Warning: bit-reversed HDLC frame, reversing bit order
efax: 29:25 received 16 bytes:
efax: 29:25 ff c0 04 00 00 6a aa aa 00 31 09 01 1e b0 db 93
efax: 29:25 received NSF - answering features
efax: 29:25 ======================= command "AT+FRH=3" +++++++++++++++++++++
efax: 29:25 waiting 35 s
efax: 29:25 .456 [CONNECT]
efax: 29:25 response "CONNECT"
efax: 29:25 waiting 2 s
efax: 29:25 .466 [OK]
efax: 29:25 response "OK"
efax: 29:25 received 25 bytes:
efax: 29:25 ff c0 02 4c 0c ec 0c cc ec 9c ac ec 4c 0c 04 04
efax: 29:25 04 04 04 04 04 04 04 bd 26
efax: 29:25 received CSI - answering ID
efax: 29:25 remote ID -> 02759730702
efax: 29:25 ======================= command "AT+FRH=3" +++++++++++++++++++++
efax: 29:25 waiting 35 s
efax: 29:25 .496 [CONNECT]
efax: 29:25 response "CONNECT"
efax: 29:25 waiting 2 s
efax: 29:25 .506 [OK]
efax: 29:25 response "OK"
efax: 29:25 received 11 bytes:
efax: 29:25 ff c8 01 00 77 15 23 01 88 e7 cd
efax: 29:25 received DIS - answering capabilities
efax: 29:25 remote has no document(s) to send, and can receive
efax: 29:25 local 98lpi 14.4kbps 8.5"/215mm any 1D - - 0ms
efax: 29:25 remote 196lpi 14.4kbps 8.5"/215mm any 2D ECM-64 - 10ms
efax: 29:25 session 98lpi 14.4kbps 8.5"/215mm any 1D - - 10ms
efax: 29:25 ======================= command "AT+FTH=3" +++++++++++++++++++++
efax: 29:25 waiting 3 s
efax: 29:25 .546 [CONNECT]
efax: 29:25 response "CONNECT"
efax: 29:25 sent 23 bytes:
efax: 29:25 ff c0 c2 ac ac ac ac 04 ac ac ac 04 0c 0c 1c 04
efax: 29:25 8c d4 04 04 04 04 04
efax: 29:25 sent TSI - caller ID
efax: 29:25 waiting 13 s
efax: 29:26 .817 [CONNECT]
efax: 29:26 response "CONNECT"
efax: 29:26 sent 6 bytes: ff c8 c1 00 44 14
efax: 29:26 sent DCS - session format
efax: 29:26 waiting 13 s
efax: 29:27 .698 [OK]
efax: 29:27 response "OK"
efax: 29:27 ======================= command "AT+FTS=8" +++++++++++++++++++++
efax: 29:27 waiting 3 s
efax: 29:27 .798 [OK]
efax: 29:27 response "OK"
efax: 29:27 ======================= command "AT+FTM=145" +++++++++++++++++++++
efax: 29:27 waiting 3 s
efax: 29:27 .838 [CONNECT]
efax: 29:27 response "CONNECT"
efax: 29:30 waiting 30 s
efax: 29:30 .941 [OK]
efax: 29:30 response "OK"
efax: 29:30 sent TCF - channel check of 2700 bytes
efax: 29:30 ======================= command "AT+FRS=1" +++++++++++++++++++++
efax: 29:30 waiting 3 s
efax: 29:31 .021 [OK]
efax: 29:31 response "OK"
efax: 29:31 ======================= command "AT+FRH=3" +++++++++++++++++++++
efax: 29:31 waiting 3 s
efax: 29:31 .512 [CONNECT]
efax: 29:31 response "CONNECT"
efax: 29:32 waiting 2 s
efax: 29:32 .503 [OK]
efax: 29:32 response "OK"
efax: 29:32 received 5 bytes: ff c8 21 57 be
efax: 29:32 received CFR - channel OK
efax: 29:32 ======================= command "AT+FTM=146" +++++++++++++++++++++
efax: 29:32 waiting 3 s
efax: 29:32 .543 [CONNECT]
efax: 29:32 response "CONNECT"
efax: 29:32 padding to 18 bytes/scan line.
efax: 29:32 header:[1927/09/19 04:29 +1 800 555 5555 Put Your Name Here p. 1/1]
efax: 29:42 waiting 30 s
efax: 29:44 .224 [OK]
efax: 29:44 response "OK"
efax: 29:44 sent 20+1064 lines, 4445+15949 bytes, 12 s 13596 bps
efax: 29:44 ======================= command "AT+FTS=8" +++++++++++++++++++++
efax: 29:44 waiting 3 s
efax: 29:44 .324 [OK]
efax: 29:44 response "OK"
efax: 29:44 ======================= command "AT+FTH=3" +++++++++++++++++++++
efax: 29:44 waiting 3 s
efax: 29:44 .374 [CONNECT]
efax: 29:44 response "CONNECT"
efax: 29:44 sent 3 bytes: ff c8 f4
efax: 29:44 sent EOP - done
efax: 29:44 waiting 13 s
efax: 29:45 .696 [OK]
efax: 29:45 response "OK"
efax: 29:45 ======================= command "AT+FRH=3" +++++++++++++++++++++
efax: 29:45 waiting 3 s
efax: 29:46 .146 [CONNECT]
efax: 29:46 response "CONNECT"
efax: 29:47 waiting 2 s
efax: 29:47 .148 [OK]
efax: 29:47 response "OK"
efax: 29:47 received 5 bytes: ff c8 31 45 8f
efax: 29:47 received MCF - page OK
efax: 29:47 sent -> test.001
efax: 29:47 ======================= command "AT+FTH=3" +++++++++++++++++++++
efax: 29:47 waiting 3 s
efax: 29:47 .187 [CONNECT]
efax: 29:47 response "CONNECT"
efax: 29:47 sent 3 bytes: ff c8 5f
efax: 29:47 sent DCN - disconnect
efax: 29:47 waiting 13 s
efax: 29:48 .509 [OK]
efax: 29:48 response "OK"
efax: 29:48 ======================= command "ATH" +++++++++++++++++++++
efax: 29:48 waiting 5 s
efax: 29:49 .079 [OK]
efax: 29:49 response "OK"
efax: 29:49 ======================= command "ATQ0V1" +++++++++++++++++++++
efax: 29:49 waiting 2 s
efax: 29:49 .189 [OK]
efax: 29:49 response "OK"
efax: 29:49 ======================= command "ATZ" +++++++++++++++++++++
efax: 29:49 waiting 5 s
efax: 29:49 .329 [OK]
efax: 29:49 response "OK"
efax: 29:49 read HDB pid 951 [ 951] from /var/lock/LCK..ttyS4 (our pid)
efax: 29:49 removed lock file /var/lock/LCK..ttyS4
efax: 29:49 done, returning 0 (success)
阅读(2269) | 评论(0) | 转发(0) |