USB-Serial programming

Discussion in 'Mac Programming' started by d1r4c, Mar 17, 2017.

  1. d1r4c macrumors newbie

    Mar 17, 2017
    Hi everyone,

    I'm currently stuck in a problem. I'm using a computer-controlled power source in order to supply current to some coils. The issue starts with the computer. For Windows there are drivers that solve it, but none for Mac nor Ubuntu/Linux.

    The source connects via USB port and is supposed to communicate through a virtual RS-232 serial port.

    I've tried solving this by treating it like a serial device, unfortunately the Mac doesn't see it like that.
    I've also tried libusb in C and pyUSB, and although I can get data from it, it's incoherent and unreadable, just what seems to be random numbers that change in every execution of the program.

    I've been searching for ways to create a virtual serial port from it, but I haven't found anything (or the little I did wasn't available) similar to this situation.

    What can I do to solve this?
    Creating a virtual port seems like the solution, but I can't find a way to do it.
  2. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    What is the exact manufacturer and model of the controllable power source?
    What is the exact OS version on the Mac?
    What software did you use to "treat it like a serial device"?
    Did you try a plain serial-port app like CoolTerm?

    Please be specific. Details are important in solving programming problems.

    The details should be such that if someone else wanted to replicate your setup exactly, they'd have all the necessary information to do so.

    If you connect the power source to the Mac's USB and run System (in /Applications/Utilities), does the power source show up as a USB device at all under the "USB" summary?

    If so, post the details of the USB device.

    Without a datasheet for the power source, I don't see how one could make any kind of driver for it.

    "Creating a virtual port" basically means having a device driver for whatever USB-connected chip resides in the power source. If that chip is a conventional USB-serial chip, such as PL2303 (Prolific) or FT232 (FTDI), then the standard driver for that chip should work. You'd still need to know the command-set for the power source, which a datasheet should tell you.

    If the USB chip in the power source isn't a typical USB-serial chip, then you'd need the datasheet for that chip. You'd still have to write a driver of some kind for it, possibly using libusb.

    Is there some reason you need to use a Mac for this, rather than a Windows machine?
    Sometimes the simplest solution is to use the manufacturer's supported solution.

    Have you considered a virtualized Windows environment running on the Mac?
    This might have USB limitations, so this approach might not work.
  3. robvas macrumors 68030

    Mar 29, 2009
    I've used a USB to serial adapter cable, which usually shows up as

Share This Page