Re: External Modem Emulator
- Posted by Ben Logan <wbljr79 at HOTMAIL.COM> Jan 27, 2000
- 581 views
>From: JJProg at CYBERBURY.NET >Reply-To: Euphoria Programming for MS-DOS <EUPHORIA at LISTSERV.MUOHIO.EDU> >To: EUPHORIA at LISTSERV.MUOHIO.EDU >Subject: Re: External Modem Emulator >Date: Wed, 26 Jan 2000 19:00:46 EST > >EU>--Modem emulator...fools computer on other end of serial cable, into >EU>thinking >EU>--it owns an external modem. > >EU>--Anything that comes in com2 is sent out com1, and anything that comes >in >EU>--com1 is sent out com2. >EU>--Some concepts are taken from E-TERM.EX--Thanks to PJB Systems >EU>--Pressing any key breaks out of the program. > >EU>without type_check > >EU>include serial.e > >EU>integer key,data,rcnt >EU>sequence rBuffer rBuffer = {} > >EU>clear_screen() >EU>puts(1,"Modem Emulator in operation...press a key to terminate...") > >EU>SetPortBPDS(1,19200,0,8,1) --Configure the ports >EU>SetPortBPDS(2,19200,0,8,1) > >EU>rcnt = 0 >EU>key = -1 >EU>while key < 0 do >EU> data = GetSerialByte(2) --See if modem has sent any data >EU> if data > 0 then >EU> rBuffer &= data --Yes, so put it in buffer >EU> rcnt = 200 --This must be 200 in order not to lose data >EU> else >EU> rcnt = rcnt -1 >EU> end if >EU> if rcnt < 1 then >EU> rcnt = 0 >EU> key = get_key() --If user has pressed a key, then exit prog >EU> if length(rBuffer) > 0 then --If there's anything in buffer, >EU> for i = 1 to length(rBuffer) do --Send it out >EU> SendSerialByte(1,rBuffer[i]) --com1 >EU> end for >EU> rBuffer = {} --Empty the buffer >EU> end if >EU> data = GetSerialByte(1) --Get data from com1 (remote 'puter) >EU> if data > 0 then --If any data was waiting, >EU> SendSerialByte(2,data) --send it to modem >EU> end if >EU> end if >EU>end while >EU>puts(1,"\n\nDone.\n") >EU>------------------------------------------------- > >EU>Thanks in advance, > >EU>Ben > >EU>______________________________________________________ >EU>Get Your Private, Free Email at http://www.hotmail.com > >Try writing as much in assembly as possible, so that it goes faster. >For example, try this: > >push edx ; Save the registers >push eax >mov dx, 765 ; COM2 data ready >in al, dx >and al, 1 >cmp al, 0 ; Is data ready? >je noMoreData ; No >mov dx, 760 ; COM2 input >in al, dx >mov dx, 1016 ; COM1 output >out dx, al >noMoreData: >pop eax ; Restore registers and return >pop edx >ret > >I haven't tested it, though. > >Jeff Looks like it will work, but I'm not sure how to implement it in Euphoria. In particular, how do I know what address to poke in for a label when I don't know where it will be loaded into memory. I looked at Pete's asm.e, but will it resolve the addresses? Also, do you think that the assembly language code will be fast enough, that I can eliminate the buffer? If not, how do I add a byte to the sequence (rBuffer in the above code) from the asm routine? Thanks again, Ben ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com