I'm playing around with a Redpark Serial Cable and the External Accessory Framework to be able to talk to a device through ModBus RTU using libmodbus. I found an objective-c wrapper that I have already used to do this through ModBus TCP.
I am having trouble getting the library to use the Serial Cable as the device to connect. I was wondering if anyone has tried doing this before.
My question really is how does iOS "talk" to the external accessory? What are the paths to these port locations?
I believe in OSX these paths lie in the /dev directory
I am trying to use the following function
modbus_t *modbus_new_rtu(const char *device, int baud, char parity, int data_bit, int stop_bit);
Here is the documentation.
From my brief research on the Redpark Lightning Serial Cable, the cable works with the Rsc Mgr SDK. I suspect you'll need to port libmodbus to iOS using the Rsc Mgr SDK for access to the serial data rather than having libmodbus open a serial port directly.
When the iOS accessory manager receives data from the cable and we
receive an event that data is available in the read stream, the
readBytesAvailable call is made - source
iOS appears to talk to the external accessory via the iOS accessory manager.
This may be a bit late for an answer but I'll give it a go anyway. You will have to modify the Modbus RTU implementation in the original libmodbus using the redpark sdk interface read/write methods. And adapting the serial settings to the redpark sdk. A decent guideline may be to look at the Arduino implementation for libmodbus. It has modifications to run on Arduino. And since the Redpark SDK is objective C, the libmodbus files will need to be changed to a '.m' extension.
Related
I'm attempting to send data between an iPad and Arduino via Bluetooth.
I read several online tutorials but I'm confused about the UUIDs used in them.
How do I find the UUIDs used by services and characteristics for the specific Bluetooth module connected to the Arduino?
Is there an AT command for this? Can they be set? Are they a constant?
This a pretty simple app and I have the Bluetooth communicating with the Arduino via the Terminal program on my Mac. The iOS app just needs to transmit and receive a few bytes of data. Do I really need all the code involved with Core Bluetooth or is there an easier way? What's the simplest, fastest way to implement 2 way communication of a few bytes via Bluetooth?
It appears that a HC-06 Bluetooth module in not BLE and is not compatable with iOS devices. I have succeeded connecting it to my Mac and have written a test app using ORSSerialPort
This app promises to turn your iOS device into a second monitor and uses the standard USB cable to connect to the computer, as opposed to the network which all other similar apps use.
Back when I heard about it, it wasn't yet available so I thought it was a scam. To my surprise, they released the app and it actually works as described.
How does it work ? As far as I know there are no APIs to drive the USB port in iOS, and the computer connected via USB through the standard charging/syncing cable doesn't count as an MFI accessory.
Note that they provide the server software (the one that installs on the Mac and streams the desktop to the device) on their download page for free, reverse-engineering it could shed some light on this but I unfortunately don't have the skills for that.
Dean told about it on his blog.
Duet uses Peertalk, an open source library allowing to pass TCP connections through the USB connection without being part of the MFI program.
The information, code and tools to accomplish generic USB port communication is available to those who join the Apple MFi program. You have to do the paperwork and get licensed by Apple.
http://developer.apple.com/programs/mfi/
The libraries necessary are included in the app and then the usual streaming libraries and code do the rest.
Given I have a bluetooth device which returns some serial data - how do I read it using CoreBluetooth?
There is no Characteristics or Services. Just some binary data in known (actually obd ii) format.
I think iOS blocks the access to the serial port over bluetooth.
You might need to buy extra hardware, use WiFi, or jailbreak it.
RS232 for iOS device
Try using roqyOBD if you manage to jailbreak your iPhone. I believe that it creates a TCP server that you can use FuzzyLuke's OBD2Kit and thus read the PID's that are sent from the OBD-II interface to the iPhone.
Let me know how it goes! I myself am tinkering OBD-II with iPhone and am learning just like you.
You probably have a Bluetooth 2.0 or 3.0 device which is not BTLE compliant. CoreBluetooth is an implementation of BTLE, hence you can't use said device on (non-jailbroken) iOS. There are a lot of BTLE compliant devices these days, so better get one of those, if you want to interface with iOS.
I am doing some experimenting with robotics and have a USB servo controller that I would like to connect to my iPad. Does anyone know if it's possible to access USB devices such as this on the iPad? And if so, what mechanisms can I use to talk to it? The servo controller's manufacturer has made the controller's protocol open so if I can talk to it, I should be able to use it.
It is most likley you will not be able to control the servo DIRECTLY form the iphone.
A servo is controller by some sort of "servo-controller"
And this server is controlled using an RS232 interface that accepts commands in some sort of characters or bits.
So I found this rs-232 app that looks interesting on app-store but not sure how to use it?
But you can buy cables like this for iphones and ipads Keep in mind that RS232 and TTL use different voltages.
Instead of getting more hardware for the iPhone / iPad, use the built in Bluetooth and the SPP (Serial Port Interface) with some code and this excellent piece of kit (i use it often it great) This just needs some power (it runs on TTL#9600bps not RS232 so check for voltage compatibility) you pair it and get a proper virtual COM port to communicate over Bluetooth without any special programming! You need to check if you iOS allows you to use SPP Bluetooth Profile. A lot of older iOS devices do not allow much over Bluetooth- so you might need a cable.
There is nice project here on how to use serial on iOS
And here is way to use Bluetooth HID included in most iPhones / iPad with a clever device that re transmits it using Bluetooth SPP .. hehehe - Suck on that Steve
And here on spark fun is a ready product. whatever you type on the iPhone (or using a programme that pushes characters to Bluetooth HID) which get converted to TTL...
You can use the ExternalAccessory.framework and its APIs.
There's also a brief guide on External Accessories.
Does iOS SDK provide a way to let iOS app talk to app running in OSX/Windows via usb cable connection?
Or, socket is the only option?
If you want to interact with an OS X program from iOS via USB, the PeerTalk lib seems to provide a convenient way to do so (without having to join the MFi program).
According to the github page, PeerTalk
Provides you with USB device attach/detach events and attached device's info
Can connect to TCP services on supported attached devices (e.g. an iPhone), bridging the communication over USB transport
Offers a higher-level API (PTChannel and PTProtocol) for convenient implementations.
[is] Tested and designed for libdispatch (aka Grand Central Dispatch).
It also
has successfully been released on both the iOS and OS X app store.
A great example is Duet Display which is a fantastic piece of software allowing you to use your iDevice as an extra display for your Mac using the Lightning or 30-pin cable. [...]
Communication via USB cable is possible but everything is under strict MFi NDA.
One link that might interest you:
Microchip: 3-step Approach to Develop iPod®, iPhone® and iPad® Accessories
Some more information on Apple MFi program
There are no fees to enter the program but you will have to fill out some 'paperwork'.