• 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: A Byte out of USB
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A Byte out of USB


  • Subject: Re: A Byte out of USB
  • From: "Edward K. Chew" <email@hidden>
  • Date: Wed, 19 Mar 2008 18:21:23 -0400

On 12-Mar-08, at 5:09 PM, Hank Heijink (Mailinglists) wrote:


On Mar 12, 2008, at 4:51 PM, Dave Camp wrote:

On Mar 12, 2008, at 1:35 PM, R T wrote:

This may be the wrong list to ask this question, if so
maybe you can guide me.
Back in the days of OS 9 I wrote a block of code that
sent a byte of information out the serial port. The
byte went to a microcontroller of a machine. At the
time I wrote it in Hypercard.
I want to use  Xcode/Applescript to send this same
byte of information out the USB port from my new
MacBook running 10.5.2.
Is there a sample block of code somewhere that shows
how to accomplish sending 1 byte out a USB Port?

USB doesn't work like that. You can learn more about USB at <http://www.usb.org >.


If what you really need is a serial connection to a external RS232 device you should purchase a USB to RS232 adaptor (KeySpan makes some nice devices - <http://www.keyspan.com> ). Then the question becomes: how do I communicate with a serial port? I think there is some sample code on the Apple dev site or pretty much any Unix example will probably work. KeySpan also has sample code on their Support page.

Apple's sample code (I think it's just called SerialPort) works beautifully with the Keyspan adaptors with a little tweak here and there. I used it as a starting point to port some old Hypercard code to MacOS 10.4 at the time through a Keyspan adaptor attached to the USB port.



I think the sample code in question can be found here:

http://developer.apple.com/samplecode/SerialPortSample/

There's a bit of preamble where you need to query IOKit for a list of serial devices (there could be more than one on the same bus, after all), pick the one you want, and get your terminal settings in order. The sample code helps you with all that. Then you just read and write to the port with calls like, well, "read" and "write". It gets pretty simple at that point.

-Ted

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >A Byte out of USB (From: R T <email@hidden>)
 >Re: A Byte out of USB (From: Dave Camp <email@hidden>)
 >Re: A Byte out of USB (From: "Hank Heijink (Mailinglists)" <email@hidden>)

  • Prev by Date: Re: Animation in Size Inspector fo IB 3.x
  • Next by Date: Re: Why doesn't FileMerge work?
  • Previous by thread: Re: A Byte out of USB
  • Next by thread: Re: A Byte out of USB
  • Index(es):
    • Date
    • Thread