串口通讯编程(160分)

P

plwei

Unregistered / Unconfirmed
GUEST, unregistred user!
1.我想搞一个通过MODEM—电话线——MODEM互相进行文件传输的程序.(与异
地的多台机子进行通讯).请大家给我一些建议,最好能给我一个简简单单的
例子。
2.在一只MODEM用其它软件拔通以后,怎样再用自己的程序去侦测它的状态。
由于为内置的modem有时进行通讯后忘记拆线,我想编一个程序模拟外置式
MODEM的指示灯。
将仅有的160分全部奉上每题八十。 希望各位能帮忙。
 
1. 建议你用spcomm等构件, 里面有例子.
2. 侦测状态需要用netapi, 我有个例子, 发给你吧:)
 
cytown:能给我一个吗?hntangwei@netease.com
 
CYTOWN: 能给我 NETAPI 的例子吗. 我的EMAIL: GUO_LIU@HOTMAIL.COM
 
cytown,如果我先用别的软件拔通以后再用你给我的例了子
测端口(com3)的状态,应该怎样用。
 
plwei:你的代号和我的很像.
我这有点关于串口通讯的例子.由于时间关系,我来不及看是干什么的,
贴在这,你看着办:
Serial Port Communications?

I want to build a simple electrical controller which receives
input from a sensor through a comm port and either turns
a power source(s) on or off based upon this signal. I want
this controller to be software in nature.
How do I communicate through the port and is it possible to
discern changes in voltage.
If not, what kind of signal must be input.

When you want to write and read only binary signals you can use
the printer parallel port. For that purpose the Port command is useful.
In the below an example of some D1 code used for bidirectional
2 wire bus communication (I2C). BaseAddress is $278,
$378 or $3BC, depending on the LPT port used for
communication.

There is a 'but'. In D1 the port function was available
but not documented. In
D2 and D3 it seems to have disappeared entirely
(Please somebody correct me if
this is wrong).

We are using the parallel printer port with attached a
small interface card
with some I/O buffering for control of RF modules. Could
somebody indicate
whether the Port function still exist or what the alternative
could be ?

regards,

Hans Brekelmans


PROCEDURE SetIICline(Terminal: IICterminalTypes; High: Boolean);
Var Count : Word;
CtrlAddress: word;
Begin { set iic line }
CtrlAddress:=BaseAddress+2;
Case Terminal of
SCL : if High then Port[CtrlAddress]:=$08 else Port[CtrlAddress]:=$00;
SDA : if NOT High then Port[BaseAddress]:=$80 else Port[BaseAddress]:=$00;
END;
For Count := 1 to ClockDelay do;
End; {SetIICline}

FUNCTION GetIICline(Terminal: IICterminalTypes): Boolean;
const SDA_IN=$80; { SDA: 25 pin #11, status, NOT BUSY, bit 7 }
SCL_IN=$08; { SCL: 25 pin #15, status, NOT Error, bit 3 }
var Count : Word;
ReadAddress: word;
Begin
ReadAddress:=BaseAddress+1;
CASE Terminal OF
SCL: GetIICline:=((Port[ReadAddress] AND SCL_IN) = SCL_IN);
SDA: GetIICline:=((Port[ReadAddress] AND SDA_IN) = SDA_IN);
{ read sdapin }
END;
For Count := 1 to ClockDelay do;
End;
 
plwei, 我的例子不管用什么拨号软件都可以, 关键是要用拨号网络中有的entry才
行. 建一个entry, 指向com3的modem, 就可以了.
 
两个例子都发给你了, 可以的话别忘了加分~!^
 
cytown能告诉我怎样建一个entry吗?
 
呵呵, 所谓一个entry就是一个dialupnetwork connection, 新建一个拨号网络,
然后把modem属性设成com3上的modem就可以了:)
 
CYTOWN: 能给我 NETAPI 的例子吗. 我的EMAIL:
pount@pdns.jsitec.edu.cn

 
多人接受答案了。
 
顶部