毕业论文外文翻译--RS232串口通讯(外文原文+中文翻译)Word文件下载.docx
- 文档编号:811033
- 上传时间:2023-04-29
- 格式:DOCX
- 页数:17
- 大小:54.25KB
毕业论文外文翻译--RS232串口通讯(外文原文+中文翻译)Word文件下载.docx
《毕业论文外文翻译--RS232串口通讯(外文原文+中文翻译)Word文件下载.docx》由会员分享,可在线阅读,更多相关《毕业论文外文翻译--RS232串口通讯(外文原文+中文翻译)Word文件下载.docx(17页珍藏版)》请在冰点文库上搜索。
TD
TransmitData(Serialdataoutput)
7
4
RTS
Requesttosend(acknowledgetomodemthatUARTisreadytoexchangedata
8
5
CTS
Cleartosend(i.e.;
modemisreadytoexchangedata)
6
DSR
Datareadystate(UARTestablishesalink)
SG
Signalground
1
DCD
DataCarrierdetect(Thislineisactivewhenmodemdetectsacarrier
20
DTR
DataTerminalReady.
9
22
RI
RingIndicator(BecomesactivewhenmodemdetectsringingsignalfromPSTN
AboutDTE&
DCE:
Devices,whichuseserialcablesfortheircommunication,aresplitintotwocategories.TheseareDCE(DataCommunicationsEquipment)andDTE(DataTerminalEquipment.)DataCommunicationsEquipmentsaredevicessuchasyourmodem,TAadapter,plotteretcwhileDataTerminalEquipmentisyourComputerorTerminal.AtypicalDataTerminalDeviceisacomputerandatypicalDataCommunicationsDeviceisaModem.OftenpeoplewilltalkaboutDTEtoDCEorDCEtoDCEspeeds.DTEtoDCEisthespeedbetweenyourmodemandcomputer,sometimesreferredtoasyourterminalspeed.ThisshouldrunatfasterspeedsthantheDCEtoDCEspeed.DCEtoDCEisthelinkbetweenmodems,sometimescalledthelinespeed.
Mostpeopletodaywillhave28.8Kor33.6Kmodems.Therefore,weshouldexpecttheDCEtoDCEspeedtobeeither28.8Kor33.6K.ConsideringthehighspeedofthemodemweshouldexpecttheDTEtoDCEspeedtobeabout115,200BPS.(MaximumSpeedofthe16550aUART).Thecommunicationsprogram,whichweuse,hassettingsforDCEtoDTEspeeds.However,thespeedis9.6KBPS,144KBPSetcandthemodemspeed.
Ifweweretransferringthattextfileat28.8K(DCE-DCE),thenwhenthemodemcompressesityouareactuallytransferring115.2KBPSbetweencomputersandthushaveaDCE-DTEspeedof115.2KBPS.Thus,thisiswhytheDCE-DTEshouldbemuchhigherthanthemodem'
sconnectionspeed.Therefore,ifourDTEtoDCEspeedisseveraltimesfasterthanourDCEtoDCEspeedthePCcansenddatatoyourmodemat115,200BPS.
WhatisNULLMODEM?
NullmodemisusedtoconnecttwoDTE'
stogether.ThisisusedtotransferfilesbetweenthecomputersusingprotocolslikeZmodemprotocol,xmodemprotocol,etc
Figure:
AboveshowstheconnectionsoftheNullmodemusingRS-232Dconnecter
Above-mentionedfigureshowsthewiringofthenullmodem.Themainfeatureindicatedhereisthatthetomakethecomputertochatwiththemodemratherthananothercomputer.Theguest&
hostcomputerconnectedthroughtheTD,RD,andSGpins.AnydatathatistransmittedthroughTDlinefromtheHosttoGuestisreceivedonRDline.TheGuestcomputermusthavethesamesetupastheHost.Thesignal
ground(SG)lineofthebothmustbeshortedsothatgroundsarecommontoeachcomputer.
TheDataTerminalReady(DTR)isloopedbacktoDataSetReadyandCarrierDetectonbothcomputers.WhentheDataTerminalReadyisassertedactive,thentheDataSetReadyandCarrierDetectimmediatelybecomeactive.Atthispoint,thecomputerthinkstheVirtualModemtowhichitisconnectedisreadyandhasdetectedthecarrieroftheothermodem.
AlllefttoworryaboutnowistheRequesttoSendandClearToSend.Asboth
computerscommunicatetogetheratthesamespeed,flowcontrolisnotneededthusthesetwolinesarealsolinkedtogetheroneachcomputer.Whenthecomputerwishestosenddata,itassertstheRequesttoSendhighandasitishookedtogetherwiththeCleartoSend,Itimmediatelygetsareplythatitisoktosendanddoesso.
TheRingindicatorlineisonlyusedtotellthecomputerthatthereisaringingsignalonthephoneline.Aswedonothave,amodemconnectedtothephonelinethisisleftdisconnected
ToknowabouttheRS232portsavailableinyourcomputer,Rightclickon"
MyComputer"
Goto'
Properties'
Selecttab'
DeviceManager'
gotoPorts(COM&
LPT),
Inthatyouwillfind'
CommunicationPort(Com1)'
etc.Ifyourightclickonthatandgotoproperties,youwillgetdevicestatus.Makesurethatyouhaveenabledtheport(Usethisportisselected).
HowtoprogramtheSerialPortusingC/C++?
TherearetwopopularmethodsofsendingdatatoorfromtheserialportinTurboC.Oneisusingoutportb(PORT_ID,DATA)oroutport(PORT_ID,DATA)definedin“dos.h”.Anothermethodisusingbioscom()functiondefinedin“bios.h”.Usingoutportb():
Thefunctionoutportb()sendsadatabytetotheport‘PORT_ID’.Thefunctionoutport()sendsadataword.Thesefunctionscanbeusedforanyportincludingserialport,parallelports.Similarlytoreceivedatatheseareused.
·
inportreadsawordfromahardwareport
inportbreadsabytefromahardwareport
outportoutputsawordtoahardwareport
outportboutputsabytetoahardwareportDeclaration:
intinport(intportid);
unsignedcharinportb(intportid);
voidoutport(intportid,intvalue);
voidoutportb(intportid,unsignedcharvalue);
Remarks:
inportworksjustlikethe80x86instructionIN.Itreadsthelowbyteofawordfromportid,thehighbytefromportid+2.
inportbisamacrothatreadsabyte
outportworksjustlikethe80x86instructionOUT.Itwritesthelowbyteofvaluetoportid,thehighbytetoportid+1.
outportbisamacrothatwritesvalueArgumentportid:
Inport-portthatinportandinportbreadfrom;
Outport-portthatoutportandoutportbwritetovalue:
Wordthatoutportwritestoportid;
Byte-thatoutportbwritestoportid.
Ifyoucallinportboroutportbwhendos.hhasbeenincluded,theyaretreatedasmacrosthatexpandtoinlinecode.
Ifyoudon'
tincludedos.h,orifyoudoincludedos.hand#undefthemacro(s),yougetthefunction(s)ofthesamename.
ReturnValue:
#inportandinportbreturnthevalueread#outportandoutportbdonotreturn
Formoredetailsofthesefunctionsreadarticlefrom
Usingbioscom:
Themacrobioscom()andfunction_bios_serialcom()areusedinthismethodintheserialcommunicationusingRS-232connecter.Firstwehavetosettheportwiththesettingsdependingonourneedandavailability.Inthismethod,samefunctionisusedtomakethesettingsusingcontrolword,tosenddatatotheportandcheckthestatusoftheport.Theseactionsaredistinguishedusingthefirstparameterofthefunction.Alongwiththatwearesendingdataandtheporttobeusedtocommunicate.
HerearethedeatailsoftheTurboCFunctionsforcommunicationports.
Declaration:
bioscom(intcmd,charabyte,intport)
_bios_serialcom(intcmd,intport,charabyte)
bioscom()and_bios_serialcom()usesthebiosinterrupt0x14toperformvariouscommunicatetheserialcommunicationovertheI/Oportsgiveninport.
cmd:
TheI/Ooperationtobeperformed.
cmd(boiscom)
cmd(_bios_serialcom)
Action
_COM_INIT
Initialisetheparameterstotheport
_COM_SEND
Sendthecharactertotheport
_COM_RECEIVE
Receivecharacterfromtheport
_COM_STATUS
Returns rhe current status of thecommunicationport
portid:
porttowhichdataistobesentorfromwhichdataistoberead.0:
COM1
1:
COM2
2:
COM3
abyte:
Whencmd=2or3(_COM_SENDor_COM_RECEIVE)parameterabyteisignored.
Whencmd=0(_COM_INIT),abyteisanORcombinationofthefollowingbits(Onefromeachgroup):
valueofabyte
Meaning
Bioscom
_bios_serialcom
0x02
0x03
_COM_CHR7
_COM_CHR8
7databits
8databits
0x00
0x04
_COM_STOP1
_COM_STOP2
1stopbit
2stopbits
0x08
0X10
_COM_NOPARITY
_COM_ODDPARITY
_COM_EVENPARITY
NoparityOddparityEvenparity
0x20
0x40
0x60
0x80
0xA0
0xC0
0xE0
_COM_110
_COM_150
_COM_300
_COM_600
_COM_1200
_COM_2400
_COM_4800
_COM_9600
110baud
150baud
300baud
600baud
1200baud
2400baud
4800baud
9600baud
Forexample,ifabyte=0x8B=(0x80|0x08|0x00|0x03)=(_COM_1200|COM_ODDPARITY|_COM_STOP1|_COM_CHR8)
hecommunicationsportissetto1200baud (0x80=_COM_1200)
Oddparity(0x08=_COM_ODDPARITY)1stopbit(0x00=_COM_STOP1)
8databits(0x03=_COM_CHR8)
Toinitialisetheportwithabovesettingswehavetowritebioscom(0,0x8B,0);
TosendadatatoCOM1,theformatofthefunctionwillbebioscom(1,data,0).Similarlybiosco
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 毕业论文 外文 翻译 RS232 串口 通讯 原文 中文翻译
![提示](https://static.bingdoc.com/images/bang_tan.gif)