[futurebasic] Re: [FB] USB?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2000 : Group Archive : Group : All Groups

From: Deepesh Letap <DLetap@...>
Date: Thu, 02 Mar 2000 23:13:43 +0000
Robin

> 5. As I wrote earlier, the above techniques work on an iMac for serial comms
> over the USB (a keyspan USB to serial adaptor), over the iMac internal
> modem, and over the standard serial interface on a G3. That's all I've
> tested so far. But it's looking good to me. I haven't tried USB comms other
> than to the keyspan.

If it is any help, I previously went through the exact same process and came
with the same result on an iMac used for testing. I also recently bought the
Keyspan 28x (the new version released in January in England) and found it
behaved exactly as you described.

However, I also previously used the same logic to determine the default
modem port, or modem location to be more precise, using the text phrase
"modem" and came across a problem which I initially overlooked.

In short, once you find the serial ports, send it a simple Hayes AT command
and you should get OK as the result. This confirms you are connected to a
modem. Start your dialling process. If the error is one of no dialling tone,
close the port, and start again. This time skip the previously found serial
port and look at the next serial port. Then try to the AT stuff again. Why?

Basically, I went to a friend to test the code on his machine. He had a
Performa type PowerMac with an internal 14.4 modem. For obvious use, he
subsequently bought an external 56K serial modem but retained the internal
modem for faxing and using the Apple Phone and Fax software which only works
with the internal Express Modem. When he wanted to use the external modem,
he would unplug the internal modem from the phone socket and plug in the
external modem. Both modems were permanently connected to his Mac. The
external modem was connected to the printer port.

When the original code ran, it found the internal modem and tried to access
it. Obviously no dial tone so it returned an error. A valid modem but the
wrong one.

You would still return the no dial tone error if none of the modems found a
dial tone.

I eventually abandoned the original idea when progress on other software
demanded more time!

Hope this helps,

Deep








> From: Robin <robinc@...>
> Reply-To: futurebasic@...
> Date: Thu, 02 Mar 2000 08:40:07 +1000
> To: <futurebasic@...>
> Subject: Re: [FB] USB?
> 
>>>> How's it coming with the USB for FB^3 with regard to printer and modem
>>>> ports? I know that USB replaces the modem and printer ports -- but, we
>>>> still need a way to communicate with things that did use these ports. Any
>>>> analysis or code yet?
>>> 
>>> I was under the impression that OPEN "C" seamlessly handled both USB and
>>> normal ports. Is this incorrect? OPEN "C" definitely handles "normal" ports
>>> added to an iMac via a keyspan USB adaptor, the iMac's internal modem, and a
>>> modem connected to the standard serial port of a G3.
>>> --
>>> Robin
>> 
>> Robin:
>> 
>> I hope that it is, but I don't know. What I really need is an iMac to test
>> this out.
>> 
>> This is similar to  -- I also assumed that constants like _printer and
>> _modem worked on all machines, but I found out the hard way that the new
>> way of using the communication toolbox, did not work that way. Instead, you
>> have inspect a list to see what ports are available and then use one from
>> those. For example, my laptop 1400 does not have a _modem or a _printer
>> port -- instead, it has a _printermodem port.
> 
> OK, I thought you might have known something I didn't about it *not*
> working. I have done some work on serial comms in my ports from II to ^3 and
> this is what I've found:
> 
> 1. Correct, _modemPort can't be relied on. You have to do a search of the
> ports. Fortunately the Runtime is (at least, it looks to me) designed to
> cope with both "old" and "CTB". On my iMac, port -1 (= _modemPort) is
> "Printer Port USB" (one of the keyspan ports off the USB), port -2 (=
> _printerPort) is "Key USB P#2" (the other keyspan port), and port -3 is the
> internal modem. (Note: a keyspan is a device that fits onto the USB port and
> gives you two "standard" Mac serial ports out the other end which are
> selectable as serial ports via the communications toolbox).
> 
> 2. Because of (1) I no longer use _modemPort. Programs that use the serial
> port now use a saved variable to record the default port (and allow the user
> to select it from a popup). Modified from the docs, this is how I find the
> "modem" port:
> 
> local
> dim modemPort,num,i
> local fn findModemPort
> 'with USB, _modemPort is not necessarily the modem port!
> FN FBInitSerialPorts    ' make sure this is done here or earlier
> modemPort = _modemPort
> num = gFBSerialPortCount%
> for i=1 to num
> if instr(1,ucase$(gFBSerialName$(i)),"MODEM")>0 then¬
> modemPort = -i:   i = num
> next
> end fn = modemPort
> 
> 3. I haven't yet worked out definitively whether the number found in (2) can
> be trusted from run to run on a constant physical system. It seems to be OK..
> But it would be safer to store the name rather than the number and work out
> the port ID each time, especially in public-release software. Certainly the
> IDs change if you change the physical system. When I start the iMac with the
> keyspan connected, it gives the results in (1). If I then pull the keyspan
> off, the internal modem becomes Port -1. If I put it back in, the internal
> modem stays as port -1 and the 2 keyspan ports become -2 and -3.
> 
> 4. Since USB is supposed to be hot-swappable, it is probably best
> programming practice to use the name of the selected serial port and do an
> FN FBInitSerialPorts and name-search each time you *open* the port, rather
> than each time the app starts.
> 
> 5. As I wrote earlier, the above techniques work on an iMac for serial comms
> over the USB (a keyspan USB to serial adaptor), over the iMac internal
> modem, and over the standard serial interface on a G3. That's all I've
> tested so far. But it's looking good to me. I haven't tried USB comms other
> than to the keyspan.
> 
> -- 
> Robin
> ====================================================
> Genesearch Pty Ltd
> E-mail: robinc@...
> WWW:    http://www.genesearch.com.au
> ====================================================
> 
> 
> 
> --
> To unsubscribe, send ANY message to <futurebasic-unsubscribe@...>
>