Keyboard and Bluetooth killed when establishing FTDI USB Serial connection - macos

Okay, when I establish a connection using LabVIEW or Python to my Arduino Duemilanove (ATMega328) either my Bluetooth or keyboard is killed.
I am simply trying to establish a connection to /dev/cu.usbserial-A9007UZh (or tty.usbserial-A9007UZh, but that seems to kill the keyboard or bluetooth even after Terminal is shut down when using python).
I am on a MacbookPro, and I have found that the keyboard is on the same USB hub that one of the two USB slots is on, and the bluetooth is on the same USB hub that the other of the two USB slots is on, which explains the association between those two devices - but what is causing the loss of the other devices?
when I use Arduino (programming IDE) or Cornflake to open a serial connection there are no errors -- and everything works as expected. This just seems to happen with LabVIEW and Python.
I am on Snow Leopard 10.6.2 and have the latest FTDI USB drivers and am running in 32-bit mode.

Based on correspondence with FTDI, there seems to be a known problem with OS X drivers that can result in "complete system crash" from which "there is no way to recover". They recommend architecting software to use a dedicated thread for serial communications to ensure input data (aka, data transmitted by the device and received by OS X) is read promptly.
They mention that new "certified" (signed?) drivers should be available for OS X in Spring 2015, but don't mention if this particular problem will be solved in this new release.
Anecdotally, I have not experienced Bluetooth/keyboard crashes using OS X 10.10.2 with the built-in AppleUSBFTDI.kext drivers.

Related

Are serial port or Serial.Write working differently on Mac and Windows?

I am trying to write a Xojo app to communicate with a device (a ZVT-ECash Terminal) that is connected to my Mac through a USB/Serial adapter.
I am testing my app on OS X and on Windows 7 (running under Parallels).
In both cases I'm sending a string (always the same one) through Serial.Write somehow like that:
command = chrb(&h10) + chrb(&h02) + chrb(&h06) + chrb(&h00) +chrb(4)...
Serial1.Write(command)
Serial1 is an instance of the Serial control.
This string is acknowledged by the device as a valid command when I run my app on Windows and is not acknowledged on OS X (the device answers with a NAK).
On OS X I have also tried to send the same string manually with CoolTerm and it was not acknowledged either.
What am I doing wrong? Is it some problem with the Serial control in Xojo, and/or is there some general difference in how the serial port works under Win and OS X?
I have run into similar problems myself just recently. Turned out it had nothing to do with Xojo (even though CoolTerm is written in Xojo as well).
The problem was with the OS X driver for the adapter that is using the "2303" Prolific chip. I found that both the driver by Prolific and the open source version (osx.pl2303) had issues: The former did not always set the baud rate correctly whereas the latter did not handle the hardware handshake properly. My solution was to purchase the driver from https://www.mac-usb-serial.com - it was the only one that worked for me on OS X with two different 2303-based adapters.

Maintaining a Windows Bluetooth Connection

I'm manufacturing a device that connects to my computer using Bluetooth and then a desktop Java app uses the Bluetooth connection to send serial data to the device which is then displayed.
When I try to connect my device to windows 7 it successfully finds and pairs with it creating a Bluetooth link on a COM port. This link can then be used by a serial prompt (used for testing) or my Java application. It works initially however soon after windows drops the connection and the only way to reconnect is to delete the device within devices and printers and then reconnect.
This seems to be a known problem with windows bluetooth so I decieded to use a third party Bluetooth application. I downloaded and tried Toshiba's Bluetooth Stack and it was able to add a Bluetooth device and keep a stable connection which works great however this only works for Toshiba computers without getting a cracked version.
This device is commercial and can't be sold with cracked versions of software. Has anybody experienced the same problems or not in other operating systems and has any solutions of advice as that would be a tremendous help.
This is not a good idea/method to use the COM ports generated by Windows, it's not working fine and not reliable in any scenario ; you should use Bluetooth Sockets instead.
Using Toshiba or Widcomm or BleuSoleil won't help: under Win7, all dongles are now trying to use the Microsoft Stack, not their own implementation.

Virtual HID-keyboard for OS X

I'm trying to create a virtual bluetooth keyboard client for Mac OS. that means my Mac will serve as a BT KB. I read about the bluetooth API in OS X (in ObjC), and I also found an HID API for Mac (in C)
To make this work I understand I need to declare an hid-keyboard-service that should be broadcasted on SDP queries.
if I declare an HID service using the HID API, is my service visible/broadcasted on Bluetooth too? (the documents seems to refer to HID with regards to USB only). - are HID services visible on both bluetooth and USB interfaces, and the underlaying connection is transparent to me?
is there any code that will help me with this you know about? I prefer ObjC, but it seems HID API is C only... :(
Thanks...!
As far as I understand it, a HID device driver represents a device locally to the OS, and by the OS, to various other components. It is not used to "broadcast" on USB nor on Bluetooth. As far as I know, OS X does not include a Bluetooth HID service, and neither does OS X nor the USB chipsets in Macs support USB device mode -- or at least they do not expose it.
You will want to write a Bluetooth service. I have not done that, but the documentation seems extensive. From what I understand, you would somehow have to implement your HID service based on the underlying Bluetooth L2CAP transmission protocol.
Since I have studied neither Bluetooth, nor Bluetooth support under Mac, I am unable to provide any more help. I did take a look at HID protocol specs, and even played with them. HID is relatively trivial to implement, but there will be quite a bit of work on implementing the Bluetooth service first.
It seems similar tools exist for linux and may have usable source code. See this thread for links.

How do I communicate with a GPIO USB device in OS X?

I have a USB web camera from ViMicro that contains a GPIO chip. We have a microswitch wired to one of the IO pins and can read the status of the switch on Windows using an ActiveX control that was provided by ViMicro, named exvmuvc.ax. I need to duplicate this functionality using IOKit on OS X.
USBTrace from SysNucleus displays the conversation happening between the Windows system and the USB device, but I cannot duplicate this on the Mac.
Does anyone know of a software USB sniffer, like USBTrace, that works on OS X so that I can compare the packets? Also, is anyone familiar with this particular camera chip and its GPIO subsystem, even on Linux?
You could use usbtracer from Xcode, or you can try using using USB Prober with a debug release of IOUSBFamily, this will most likely output more information than you actually want. You may want to look at qa1370 for more information.
In general though, I'd recommend you get a hardware USB analyzer, they make this sort of thing much easier.

Custom USB Driver for Windows? Mac?

I'd like to modify a USB driver to send and receive USB data over a network.
Take for example, an iMac and a PC. I have an iPod plugged in to my PC (in NY). I want my iMac (in LA) to recognize the iPod as plugged in to a local USB port and be able to communicate with the iPod.
Forget my qualifications, or lack thereof (I have background in web, iOS apps, I've toyed with Java and C).
Where can I get source code for a USB driver for Windows that I can modify? Mac OS?
Any tips or pointers towards accomplishing my goal would be appreciated as well.
It looks like folks are coming up with something close to what you want. If you do decide to roll your own, the USB driver source you asked for is libusb.
On the Mac OS X end, drivers are built up in a stack. What you want to do should be relatively simple (nothing is really simple in kernel land). You need to create a driver that can communicate over ethernet with the PC and looks like a USB device to the driver matching software. Then everything else will happen automatically.
The source code is available for Apple's USB stack. You should also read about the IOKit API and IOKit device driver guidelines and IOKit fundamentals.
Oh yes and you say you have toyed with Java and C. To write device drivers on OS X, you'll need to learn some C++.
I suggest you to go see USBIP project. This is available on Linux and Windows, but not clear for MAC. If you can get a VHCI-Controller driver installed for MAC, we can kick start USBIP for MAC.
Sounds quite like this product, a bit unsure if theirs works over wide-area networks though.
I have a general idea of how I'd go about it, but not any specifics. Basically, I'd use the platform's driver development kit to write a USB device emulator on the client machine. I'd then add a virtual device to that system called "Networked USB Host", or something similar that maintains an open port to listen for communication from the server and passes it on to your virtual USB device. IIRC, the Windows DDK comes with a USB simulation framework that might be able to help you with this.
On the server, you'd have to hook into the USB subsystem to send raw USB packets to the client machine. libpcap and wireshark have USB capturing facilities for that, but I'm not sure if this works with winpcap and the Windows version of wireshark as well.
EDIT: Look at this for cross-platform USB capture alternatives.
You can buy OSR USB learning kit: https://www.osronline.com/custom.cfm?name=index_fullframeset.cfm&pageURL=https://www.osronline.com/store/index.cfm
This is actually small USB device with known interface. Windows Driver Kit (WDK) contains sample KMDF driver for this device: http://www.microsoft.com/whdc/driver/wdk/
This is good starting point to learn Windows Drivers development, and USB drivers development specifically. However, it is still far away from your problem solution.
Can't you use some sort of Remote Desktop?

Resources