• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Modem Port
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Modem Port


  • Subject: Re: Modem Port
  • From: Mike Cohen <email@hidden>
  • Date: Thu, 14 Mar 2002 16:50:02 -0500

Check out Apple's serial port sample code for OS X. Here's the code I use to
identify the internal modem port, which I adapted from that sample:

kern_return_t ModemConnection::FindModems(io_iterator_t *matchingServices)
{
kern_return_t kernResult;
mach_port_t masterPort;
CFMutableDictionaryRef classesToMatch;
kernResult = IOMasterPort(MACH_PORT_NULL, &masterPort);
if (KERN_SUCCESS != kernResult)
return kernResult;
// Serial devices are instances of class IOSerialBSDClient
classesToMatch = IOServiceMatching(kIOSerialBSDServiceValue);
if (classesToMatch == NULL)
return KERN_FAILURE;
else {
CFDictionarySetValue(classesToMatch,
CFSTR(kIOSerialBSDTypeKey),
CFSTR(kIOSerialBSDModemType));
}
kernResult = IOServiceGetMatchingServices(masterPort, classesToMatch,
matchingServices);
return kernResult;
}

// Given an iterator across a set of modems, return the BSD path to the
first one.
// If no modems are found the path name is set to an empty string.
kern_return_t ModemConnection::GetModemPath(io_iterator_t
serialPortIterator, char *bsdPath, CFIndex maxPathSize)
{
io_object_t modemService;
kern_return_t kernResult = KERN_FAILURE;
Boolean modemFound = false;
// Initialize the returned path
*bsdPath = '\0';
while ((modemService = IOIteratorNext(serialPortIterator)) &&
!modemFound)
{
CFTypeRef modemNameAsCFString;
CFTypeRef bsdPathAsCFString;
modemNameAsCFString = IORegistryEntryCreateCFProperty(modemService,

CFSTR(kIOTTYDeviceKey),

kCFAllocatorDefault,
0);
if (modemNameAsCFString)
{
char modemName[128];
Boolean result;
result = CFStringGetCString((const
CFStringRef)modemNameAsCFString,
modemName,
sizeof(modemName),
kCFStringEncodingASCII);
CFRelease(modemNameAsCFString);
if (result)
{
DPRINT2("Serial stream name: %s\n", modemName);
modemFound = true;
kernResult = KERN_SUCCESS;
}
}
bsdPathAsCFString = IORegistryEntryCreateCFProperty(modemService,

CFSTR(kIOCalloutDeviceKey),

kCFAllocatorDefault,
0);
if (bsdPathAsCFString)
{
Boolean result;
result = CFStringGetCString((const
CFStringRef)bsdPathAsCFString,
bsdPath,
maxPathSize,
kCFStringEncodingASCII);
CFRelease(bsdPathAsCFString);
}
(void) IOObjectRelease(modemService);
}
return kernResult;
}

On 3/14/02 1:19 PM, "email@hidden" <email@hidden> wrote:

> Hi,
>
> Maybe for Morgan it was Mac OS 9 only, but what is the
> point of writing software for the Mac OS 9 only these
> days?
>
> Adam
>> This is specifically a MacOS 9 discussion. This does not apply to X
>> or even classic . I though you were looking for specific info on how
>> to "uniquely" identify the Internal modem port.
>>
>>
>> Roger
>>
>> At 4:28 PM +0000 3/14/02, email@hidden wrote:
>>> Hi,
>>>
>>> I thought leapIn and leapOut wouldn't even be the names
>>> in Mac OS X? I think counting on leapIn/leapOut is not
>>> very robust.
>>>
>>> In my software, SoftTTY (TTY for the Mac), I want to
>>> ignore any Infrared ports when auto-configuring. What I
>>> do is filter serial ports with "irda" or "infrared" in
>>> the name (not the "." driver name or bsd path). This is
>>> good at eliminating most infrared ports and doesn't
>>> exclude any non-infrared ports.
>>>
>>> Adam
>>>
>>>
>>>> .LeapIn and .LeapOut would get you the internal modem on all
>>>> machines which Apple says is capable of running MacOS X (this entry
>>>> is only present if the modem is available) , it won't work for
>>>> earlier machines such as the first powerbook g3, or the beige g3
>>>> tower with 2 serial ports.
>>>>
>>>> In any event you should always open .aIn and .aOut (just drop in
>>>> to Macsbug and type drvr to get the correct case...) since
>>>> .LeapIn/.LeapOut is patched into the driver open call and will work
>>>> properly on a machine where .aIn really points to the modem.
>>>>
>>>> Roger
>>>>
>>>>
>>>> At 3:16 PM +0000 3/14/02, Quinn wrote:
>>>>> At 18:28 -0800 13/3/02, Morgan Redman wrote:
>>>>>> I remember a while back, I got help with how to identify which serial
>>>>>> port
>>>>>> was actually an IrDA port. ( by identifying the serial port with
>>>>>> input/output drivers named ".IrIn" / ".IrOut"
>>>>>>
>>>>>> Now I need to know how to identify which serial port is the
>>>> Internal Modem.
>>>>>>
>>>>>> the input / output driver name for the Internal Modem on my machine is
>>>>>> ".LeapIn" / ".LeapOut"
>>>>>> is this constant on all macs?
>>>>>
>>>>> Testing for these driver names is about as reliable as testing for
>>>>> ".IrIn"/".IrOut". We've never documented that this technique will
>>>>> work, but it's the best solution I know of.
>>>>>
>>>>> S+E
>>>>> --
>>>>> Quinn "The Eskimo!" <http://www.apple.com/developer/>
>>>>> Apple Developer Technical Support * Networking, Communications, Hardware
>>>>> _______________________________________________
>>>>> macnetworkprog mailing list | email@hidden
>>>>> Help/Unsubscribe/Archives:
>>>>> http://www.lists.apple.com/mailman/listinfo/macnetworkprog
>>>>> Do not post admin requests to the list. They will be ignored.
>>>>
>>>>
>>>> --
>>>> _______________________________________________
>>>> macnetworkprog mailing list | email@hidden
>>>> Help/Unsubscribe/Archives:
>>>> http://www.lists.apple.com/mailman/listinfo/macnetworkprog
>>>> Do not post admin requests to the list. They will be ignored.
>>
>>
>> --
> _______________________________________________
> macnetworkprog mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/macnetworkprog
> Do not post admin requests to the list. They will be ignored.
>
>

--
[ Mike Cohen | http://www.macmegasite.com/ ]
[ email@hidden | http://www.worldbeatplanet.com/ ]

Sound is the same for all the world - Youssou N'dour, "Eyes Open"
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Modem Port (From: email@hidden)

  • Prev by Date: Re: adding/removing DNS servers in Mac OS X
  • Next by Date: Re: Modem Port
  • Previous by thread: Re: Modem Port
  • Next by thread: Re: Modem Port
  • Index(es):
    • Date
    • Thread