• 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
Writing an "AT-Command" to a Modem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Writing an "AT-Command" to a Modem


  • Subject: Writing an "AT-Command" to a Modem
  • From: Stefan Lehrner <email@hidden>
  • Date: Tue, 23 Oct 2007 00:11:19 -0700

Hi Folks,

what is the best way to send an "AT-Command" to a Modem?

I found several ways on the Internet:

1) SerialPort Sample of Apple

// Now open the modem port we found, initialize the modem, then close it
    if (!bsdPath[0])
    {
        printf("No modem port found.\n");
        return EX_UNAVAILABLE;
    }

    fileDescriptor = OpenSerialPort(bsdPath);
    if (-1 == fileDescriptor)
    {
        return EX_IOERR;
    }

    if (InitializeModem(fileDescriptor))
    {
        printf("Modem initialized successfully.\n");
    }
    else {
        printf("Could not initialize modem.\n");
    }

2) AMSerialTest

NSString *sendString = [[inputTextField stringValue] stringByAppendingString:@"\r"];

	if(!port) {
		// open a new port if we don't already have one
		[self initPort];
	}

	if([port isOpen]) { // in case an error occured while opening the port
		[port writeString:sendString usingEncoding:NSUTF8StringEncoding error:NULL];
	}

3) NSFileHandle

myPath = modempath;
			writeFile = [NSFileHandle fileHandleForUpdatingAtPath];
			[writeFile writeData:myPath];

It looks like, that the 3rd one would be the easiest way - but where shall I put the "at-commands" there?

Thanks for your hints and tipps...

BR

Stefan
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Writing an "AT-Command" to a Modem
      • From: Andreas Mayer <email@hidden>
    • Re: Writing an "AT-Command" to a Modem
      • From: Half Activist <email@hidden>
  • Prev by Date: Re: detecting when an app is beach-balling
  • Next by Date: Re: Writing an "AT-Command" to a Modem
  • Previous by thread: NSStepper and NSMatrix
  • Next by thread: Re: Writing an "AT-Command" to a Modem
  • Index(es):
    • Date
    • Thread