├── README.md ├── uDMXrc ├── uDMX_cmds.h ├── Makefile ├── USB-IDs-for-free.txt ├── USB-ID-FAQ.txt ├── USBID-License.txt └── uDMX.c /README.md: -------------------------------------------------------------------------------- 1 | uDMX-linux 2 | ========== 3 | 4 | This is a small command-line utility to drive the www.anyma.ch/uDMX interface. 5 | It allows to set DMX values manually from the commandline. Fixtures and 6 | values can be predefined with aliases in a rc file. 7 | 8 | The initial source code comes originally from http://udmx.googlecode.com/. 9 | This repository was moved to Github since: https://github.com/mirdej/udmx/. 10 | It the original code compiled with minimal tweaks, but the result core-dumped. 11 | 12 | This is a cleaned-up and improved version, with alias support built in. 13 | 14 | You need a uDMX interface to use it, of course. 15 | 16 | Markus Baertschi, January 2015 17 | 18 | markus@markus.org 19 | 20 | -------------------------------------------------------------------------------- /uDMXrc: -------------------------------------------------------------------------------- 1 | # 2 | # sample .uDRCrc file 3 | # 4 | # Syntax: 5 | # channel 6 | # values [value] [value] [value] [value] 7 | # 8 | # - Aliases can not contain spaces 9 | # - Channel-number from 1 to 512 10 | # - Values from 0 to 255 11 | # 12 | 13 | # 3-channel relay 14 | channel relay 9 15 | channel relay1 9 16 | channel relay2 9 17 | channel relay3 9 18 | value r-off 0 19 | value r-on 255 20 | value r-alloff 0 0 0 21 | value r-allon 0 0 0 22 | 23 | # 3-channel rgb par 24 | channel par 17 25 | values p-red 255 0 0 26 | values p-green 0 255 0 27 | values p-blue 0 0 255 28 | values p-cyan 0 255 255 29 | values p-yellow 255 255 0 30 | values p-pink 255 0 255 31 | values p-white 255 255 255 32 | values p-g10 13 13 13 33 | values p-g50 127 127 127 34 | 35 | # 6-channel magic ball 36 | channel ball 1 37 | values b-red 0 255 0 0 128 0 38 | values b-green 0 0 255 0 128 0 39 | values b-blue 0 0 0 255 128 0 40 | values b-all 0 255 255 255 127 0 41 | values b-off 0 0 0 0 127 0 42 | 43 | -------------------------------------------------------------------------------- /uDMX_cmds.h: -------------------------------------------------------------------------------- 1 | #ifndef __usb_cmds_included_included__ 2 | #define __usb_cmds_included_included__ 3 | 4 | /* 5 | * usb2dmx_cmds.h 6 | * 7 | * 8 | * Created by Max Egger on 14.02.06. 9 | * 10 | */ 11 | 12 | #define cmd_SetSingleChannel 1 13 | /* usb request for cmd_SetSingleChannel: 14 | bmRequestType: ignored by device, should be USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT 15 | bRequest: cmd_SetSingleChannel 16 | wValue: value of channel to set [0 .. 255] 17 | wIndex: channel index to set [0 .. 511] 18 | wLength: ignored 19 | */ 20 | #define cmd_SetChannelRange 2 21 | /* usb request for cmd_SetChannelRange: 22 | bmRequestType: ignored by device, should be USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT 23 | bRequest: cmd_SetChannelRange 24 | wValue: number of channels to set [1 .. 512-wIndex] 25 | wIndex: index of first channel to set [0 .. 511] 26 | wLength: length of data, must be >= wValue 27 | */ 28 | 29 | #define cmd_StartBootloader 0xf8 30 | // Start Bootloader for Software updates 31 | 32 | 33 | #define err_BadChannel 1 34 | #define err_BadValue 2 35 | 36 | 37 | 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Name: Makefile 2 | # Project: PowerSwitch 3 | # Author: Christian Starkjohann 4 | # Creation Date: 2005-01-16 5 | # Tabsize: 4 6 | # Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH 7 | # License: Proprietary, free under certain conditions. See Documentation. 8 | # This Revision: $Id: Makefile,v 1.1.1.1 2006/02/15 17:55:06 cvs Exp $ 9 | 10 | 11 | # Concigure the following definitions according to your system. The powerSwitch 12 | # tool has been successfully compiled on Mac OS X, Linux and Windows. 13 | 14 | CC = gcc 15 | LIBUSB_CONFIG = libusb-config 16 | # Make sure that libusb-config is in the search path or specify a full path. 17 | # On Windows, there is no libusb-config and you must configure the options 18 | # below manually. See examples. 19 | CFLAGS = `$(LIBUSB_CONFIG) --cflags` -O -Wall -g 20 | #CFLAGS = -I/usr/local/libusb/include 21 | # On Windows replace `$(LIBUSB_CONFIG) --cflags` with appropriate "-I..." 22 | # option to ensure that usb.h is found 23 | LIBS = `$(LIBUSB_CONFIG) --libs` 24 | #LIBS = `$(LIBUSB_CONFIG) --libs` -framework CoreFoundation 25 | # You may need "-framework CoreFoundation" on Mac OS X and Darwin. 26 | #LIBS = -L/usr/local/libusb/lib/gcc -lusb 27 | # On Windows use somthing similar to the line above. 28 | 29 | all: uDMX 30 | 31 | .c.o: 32 | $(CC) $(CFLAGS) -c $< 33 | 34 | uDMX: uDMX.o 35 | $(CC) -o uDMX uDMX.o $(LIBS) 36 | 37 | clean: 38 | rm -f *.o 39 | rm -f uDMX uDMX.exe 40 | 41 | -------------------------------------------------------------------------------- /USB-IDs-for-free.txt: -------------------------------------------------------------------------------- 1 | Version 2009-08-22 2 | 3 | =========================== 4 | FREE USB-IDs FOR SHARED USE 5 | =========================== 6 | 7 | Objective Development has reserved a set of USB Product-IDs for use according 8 | to the guidelines outlined below. For more information about the concept of 9 | USB IDs please see the file USB-ID-FAQ.txt. Objective Development guarantees 10 | that the IDs listed below are not used by any USB compliant devices. 11 | 12 | 13 | ==================== 14 | MECHANISM OF SHARING 15 | ==================== 16 | 17 | From a technical point of view, two different devices can share the same USB 18 | Vendor- and Product-ID if they require the same driver on operating system 19 | level. We make use of this fact by assigning separate IDs for various device 20 | classes. On application layer, devices must be distinguished by their textual 21 | name or serial number. We offer separate sets of IDs for discrimination by 22 | textual name and for serial number. 23 | 24 | Examples for shared use of USB IDs are included with V-USB in the "examples" 25 | subdirectory. 26 | 27 | 28 | ====================================== 29 | IDs FOR DISCRIMINATION BY TEXTUAL NAME 30 | ====================================== 31 | 32 | If you use one of the IDs listed below, your device and host-side software 33 | must conform to these rules: 34 | 35 | (1) The USB device MUST provide a textual representation of the manufacturer 36 | and product identification. The manufacturer identification MUST be available 37 | at least in USB language 0x0409 (English/US). 38 | 39 | (2) The textual manufacturer identification MUST contain either an Internet 40 | domain name (e.g. "mycompany.com") registered and owned by you, or an e-mail 41 | address under your control (e.g. "myname@gmx.net"). You can embed the domain 42 | name or e-mail address in any string you like, e.g. "Objective Development 43 | http://www.obdev.at/vusb/". 44 | 45 | (3) You are responsible for retaining ownership of the domain or e-mail 46 | address for as long as any of your products are in use. 47 | 48 | (4) You may choose any string for the textual product identification, as long 49 | as this string is unique within the scope of your textual manufacturer 50 | identification. 51 | 52 | (5) Application side device look-up MUST be based on the textual manufacturer 53 | and product identification in addition to VID/PID matching. The driver 54 | matching MUST be a comparison of the entire strings, NOT a sub-string match. 55 | 56 | (6) For devices which implement a particular USB device class (e.g. HID), the 57 | operating system's default class driver MUST be used. If an operating system 58 | driver for Vendor Class devices is needed, this driver must be libusb or 59 | libusb-win32 (see http://libusb.org/ and 60 | http://libusb-win32.sourceforge.net/). 61 | 62 | Table if IDs for discrimination by textual name: 63 | 64 | PID dec (hex) | VID dec (hex) | Description of use 65 | ==============+===============+============================================ 66 | 1500 (0x05dc) | 5824 (0x16c0) | For Vendor Class devices with libusb 67 | --------------+---------------+-------------------------------------------- 68 | 1503 (0x05df) | 5824 (0x16c0) | For generic HID class devices (which are 69 | | | NOT mice, keyboards or joysticks) 70 | --------------+---------------+-------------------------------------------- 71 | 1505 (0x05e1) | 5824 (0x16c0) | For CDC-ACM class devices (modems) 72 | --------------+---------------+-------------------------------------------- 73 | 1508 (0x05e4) | 5824 (0x16c0) | For MIDI class devices 74 | --------------+---------------+-------------------------------------------- 75 | 76 | Note that Windows caches the textual product- and vendor-description for 77 | mice, keyboards and joysticks. Name-bsed discrimination is therefore not 78 | recommended for these device classes. 79 | 80 | 81 | ======================================= 82 | IDs FOR DISCRIMINATION BY SERIAL NUMBER 83 | ======================================= 84 | 85 | If you use one of the IDs listed below, your device and host-side software 86 | must conform to these rules: 87 | 88 | (1) The USB device MUST provide a textual representation of the serial 89 | number. The serial number string MUST be available at least in USB language 90 | 0x0409 (English/US). 91 | 92 | (2) The serial number MUST start with either an Internet domain name (e.g. 93 | "mycompany.com") registered and owned by you, or an e-mail address under your 94 | control (e.g. "myname@gmx.net"), both terminated with a colon (":") character. 95 | You MAY append any string you like for further discrimination of your devices. 96 | 97 | (3) You are responsible for retaining ownership of the domain or e-mail 98 | address for as long as any of your products are in use. 99 | 100 | (5) Application side device look-up MUST be based on the serial number string 101 | in addition to VID/PID matching. The matching must start at the first 102 | character of the serial number string and include the colon character 103 | terminating your domain or e-mail address. It MAY stop anywhere after that. 104 | 105 | (6) For devices which implement a particular USB device class (e.g. HID), the 106 | operating system's default class driver MUST be used. If an operating system 107 | driver for Vendor Class devices is needed, this driver must be libusb or 108 | libusb-win32 (see http://libusb.org/ and 109 | http://libusb-win32.sourceforge.net/). 110 | 111 | Table if IDs for discrimination by serial number string: 112 | 113 | PID dec (hex) | VID dec (hex) | Description of use 114 | ===============+===============+=========================================== 115 | 10200 (0x27d8) | 5824 (0x16c0) | For Vendor Class devices with libusb 116 | ---------------+---------------+------------------------------------------- 117 | 10201 (0x27d9) | 5824 (0x16c0) | For generic HID class devices (which are 118 | | | NOT mice, keyboards or joysticks) 119 | ---------------+---------------+------------------------------------------- 120 | 10202 (0x27da) | 5824 (0x16c0) | For USB Mice 121 | ---------------+---------------+------------------------------------------- 122 | 10203 (0x27db) | 5824 (0x16c0) | For USB Keyboards 123 | ---------------+---------------+------------------------------------------- 124 | 10204 (0x27db) | 5824 (0x16c0) | For USB Joysticks 125 | ---------------+---------------+------------------------------------------- 126 | 10205 (0x27dc) | 5824 (0x16c0) | For CDC-ACM class devices (modems) 127 | ---------------+---------------+------------------------------------------- 128 | 10206 (0x27dd) | 5824 (0x16c0) | For MIDI class devices 129 | ---------------+---------------+------------------------------------------- 130 | 131 | 132 | ================= 133 | ORIGIN OF USB-IDs 134 | ================= 135 | 136 | OBJECTIVE DEVELOPMENT Software GmbH has obtained all VID/PID pairs listed 137 | here from Wouter van Ooijen (see www.voti.nl) for exclusive disposition. 138 | Wouter van Ooijen has obtained the VID from the USB Implementers Forum, Inc. 139 | (see www.usb.org). The VID is registered for the company name "Van Ooijen 140 | Technische Informatica". 141 | 142 | 143 | ========== 144 | DISCLAIMER 145 | ========== 146 | 147 | OBJECTIVE DEVELOPMENT Software GmbH disclaims all liability for any 148 | problems which are caused by the shared use of these VID/PID pairs. 149 | 150 | -------------------------------------------------------------------------------- /USB-ID-FAQ.txt: -------------------------------------------------------------------------------- 1 | Version 2009-08-22 2 | 3 | ========================== 4 | WHY DO WE NEED THESE IDs? 5 | ========================== 6 | 7 | USB is more than a low level protocol for data transport. It also defines a 8 | common set of requests which must be understood by all devices. And as part 9 | of these common requests, the specification defines data structures, the 10 | USB Descriptors, which are used to describe the properties of the device. 11 | 12 | From the perspective of an operating system, it is therefore possible to find 13 | out basic properties of a device (such as e.g. the manufacturer and the name 14 | of the device) without a device-specific driver. This is essential because 15 | the operating system can choose a driver to load based on this information 16 | (Plug-And-Play). 17 | 18 | Among the most important properties in the Device Descriptor are the USB 19 | Vendor- and Product-ID. Both are 16 bit integers. The most simple form of 20 | driver matching is based on these IDs. The driver announces the Vendor- and 21 | Product-IDs of the devices it can handle and the operating system loads the 22 | appropriate driver when the device is connected. 23 | 24 | It is obvious that this technique only works if the pair Vendor- plus 25 | Product-ID is unique: Only devices which require the same driver can have the 26 | same pair of IDs. 27 | 28 | 29 | ===================================================== 30 | HOW DOES THE USB STANDARD ENSURE THAT IDs ARE UNIQUE? 31 | ===================================================== 32 | 33 | Since it is so important that USB IDs are unique, the USB Implementers Forum, 34 | Inc. (usb.org) needs a way to enforce this legally. It is not forbidden by 35 | law to build a device and assign it any random numbers as IDs. Usb.org 36 | therefore needs an agreement to regulate the use of USB IDs. The agreement 37 | binds only parties who agreed to it, of course. Everybody else is free to use 38 | any numbers for their IDs. 39 | 40 | So how can usb.org ensure that every manufacturer of USB devices enters into 41 | an agreement with them? They do it via trademark licensing. Usb.org has 42 | registered the trademark "USB", all associated logos and related terms. If 43 | you want to put an USB logo on your product or claim that it is USB 44 | compliant, you must license these trademarks from usb.org. And this is where 45 | you enter into an agreement. See the "USB-IF Trademark License Agreement and 46 | Usage Guidelines for the USB-IF Logo" at 47 | http://www.usb.org/developers/logo_license/. 48 | 49 | Licensing the USB trademarks requires that you buy a USB Vendor-ID from 50 | usb.org (one-time fee of ca. 2,000 USD), that you become a member of usb.org 51 | (yearly fee of ca. 4,000 USD) and that you meet all the technical 52 | specifications from the USB spec. 53 | 54 | This means that most hobbyists and small companies will never be able to 55 | become USB compliant, just because membership is so expensive. And you can't 56 | be compliant with a driver based on V-USB anyway, because the AVR's port pins 57 | don't meet the electrical specifications for USB. So, in principle, all 58 | hobbyists and small companies are free to choose any random numbers for their 59 | IDs. They have nothing to lose... 60 | 61 | There is one exception worth noting, though: If you use a sub-component which 62 | implements USB, the vendor of the sub-components may guarantee USB 63 | compliance. This might apply to some or all of FTDI's solutions. 64 | 65 | 66 | ======================================================================= 67 | WHY SHOULD YOU OBTAIN USB IDs EVEN IF YOU DON'T LICENSE USB TRADEMARKS? 68 | ======================================================================= 69 | 70 | You have learned in the previous section that you are free to choose any 71 | numbers for your IDs anyway. So why not do exactly this? There is still the 72 | technical issue. If you choose IDs which are already in use by somebody else, 73 | operating systems will load the wrong drivers and your device won't work. 74 | Even if you choose IDs which are not currently in use, they may be in use in 75 | the next version of the operating system or even after an automatic update. 76 | 77 | So what you need is a pair of Vendor- and Product-IDs for which you have the 78 | guarantee that no USB compliant product uses them. This implies that no 79 | operating system will ever ship with drivers responsible for these IDs. 80 | 81 | 82 | ============================================== 83 | HOW DOES OBJECTIVE DEVELOPMENT HANDLE USB IDs? 84 | ============================================== 85 | 86 | Objective Development gives away pairs of USB-IDs with their V-USB licenses. 87 | In order to ensure that these IDs are unique, Objective Development has an 88 | agreement with the company/person who has bought the USB Vendor-ID from 89 | usb.org. This agreement ensures that a range of USB Product-IDs is reserved 90 | for assignment by Objective Development and that the owner of the Vendor-ID 91 | won't give it to anybody else. 92 | 93 | This means that you have to trust three parties to ensure uniqueness of 94 | your IDs: 95 | 96 | - Objective Development, that they don't give the same PID to more than 97 | one person. 98 | - The owner of the Vendor-ID that they don't assign PIDs from the range 99 | assigned to Objective Development to anybody else. 100 | - Usb.org that they don't assign the same Vendor-ID a second time. 101 | 102 | 103 | ================================== 104 | WHO IS THE OWNER OF THE VENDOR-ID? 105 | ================================== 106 | 107 | Objective Development has obtained ranges of USB Product-IDs under two 108 | Vendor-IDs: Under Vendor-ID 5824 from Wouter van Ooijen (Van Ooijen 109 | Technische Informatica, www.voti.nl) and under Vendor-ID 8352 from Jason 110 | Kotzin (Clay Logic, www.claylogic.com). Both VID owners have received their 111 | Vendor-ID directly from usb.org. 112 | 113 | 114 | ========================================================================= 115 | CAN I USE USB-IDs FROM OBJECTIVE DEVELOPMENT WITH OTHER DRIVERS/HARDWARE? 116 | ========================================================================= 117 | 118 | The short answer is: Yes. All you get is a guarantee that the IDs are never 119 | assigned to anybody else. What more do you need? 120 | 121 | 122 | ============================ 123 | WHAT ABOUT SHARED ID PAIRS? 124 | ============================ 125 | 126 | Objective Development has reserved some PID/VID pairs for shared use. You 127 | have no guarantee of uniqueness for them, except that no USB compliant device 128 | uses them. In order to avoid technical problems, we must ensure that all 129 | devices with the same pair of IDs use the same driver on kernel level. For 130 | details, see the file USB-IDs-for-free.txt. 131 | 132 | 133 | ====================================================== 134 | I HAVE HEARD THAT SUB-LICENSING OF USB-IDs IS ILLEGAL? 135 | ====================================================== 136 | 137 | A 16 bit integer number cannot be protected by copyright laws. It is not 138 | sufficiently complex. And since none of the parties involved entered into the 139 | USB-IF Trademark License Agreement, we are not bound by this agreement. So 140 | there is no reason why it should be illegal to sub-license USB-IDs. 141 | 142 | 143 | ============================================= 144 | WHO IS LIABLE IF THERE ARE INCOMPATIBILITIES? 145 | ============================================= 146 | 147 | Objective Development disclaims all liabilities which might arise from the 148 | assignment of IDs. If you guarantee product features to your customers 149 | without proper disclaimer, YOU are liable for that. 150 | 151 | -------------------------------------------------------------------------------- /USBID-License.txt: -------------------------------------------------------------------------------- 1 | Royalty-Free Non-Exclusive Use of USB Product-IDs 2 | ================================================= 3 | 4 | Version 2009-04-13 5 | 6 | Strictly speaking, this is not a license. You can't give a license to use 7 | a simple number (such as e.g. 1500) for any purpose. This is a set of rules 8 | which should make it possible to build USB devices without the requirement 9 | for individual USB IDs. If you break one of the rules, you will run into 10 | technical problems sooner or later, but you don't risk legal trouble. 11 | 12 | 13 | OBJECTIVE DEVELOPMENT Software GmbH hereby grants you the non-exclusive 14 | right to use four USB.org vendor-ID (VID) / product-ID (PID) pairs with 15 | products based on Objective Development's firmware-only USB driver for 16 | Atmel AVR microcontrollers: 17 | 18 | * VID = 5824 (=0x16c0) / PID = 1500 (=0x5dc) for devices implementing no 19 | USB device class (vendor-class devices with USB class = 0xff). Devices 20 | using this pair will be referred to as "VENDOR CLASS" devices. 21 | 22 | * VID = 5824 (=0x16c0) / PID = 1503 (=0x5df) for HID class devices 23 | (excluding mice and keyboards). Devices using this pair will be referred 24 | to as "HID CLASS" devices. 25 | 26 | * VID = 5824 (=0x16c0) / PID = 1505 (=0x5e1) for CDC class modem devices 27 | Devices using this pair will be referred to as "CDC-ACM CLASS" devices. 28 | 29 | * VID = 5824 (=0x16c0) / PID = 1508 (=0x5e4) for MIDI class devices 30 | Devices using this pair will be referred to as "MIDI CLASS" devices. 31 | 32 | Since the granted right is non-exclusive, the same VID/PID pairs may be 33 | used by many companies and individuals for different products. To avoid 34 | conflicts, your device and host driver software MUST adhere to the rules 35 | outlined below. 36 | 37 | OBJECTIVE DEVELOPMENT Software GmbH has obtained these VID/PID pairs from 38 | Wouter van Ooijen (see www.voti.nl) for exclusive disposition. Wouter van 39 | Ooijen has obtained the VID from the USB Implementers Forum, Inc. 40 | (see www.usb.org). The VID is registered for the company name 41 | "Van Ooijen Technische Informatica". 42 | 43 | 44 | RULES AND RESTRICTIONS 45 | ====================== 46 | 47 | (1) The USB device MUST provide a textual representation of the 48 | manufacturer and product identification. The manufacturer identification 49 | MUST be available at least in USB language 0x0409 (English/US). 50 | 51 | (2) The textual manufacturer identification MUST contain either an Internet 52 | domain name (e.g. "mycompany.com") registered and owned by you, or an 53 | e-mail address under your control (e.g. "myname@gmx.net"). You can embed 54 | the domain name or e-mail address in any string you like, e.g. "Objective 55 | Development http://www.obdev.at/vusb/". 56 | 57 | (3) You are responsible for retaining ownership of the domain or e-mail 58 | address for as long as any of your products are in use. 59 | 60 | (4) You may choose any string for the textual product identification, as 61 | long as this string is unique within the scope of your textual manufacturer 62 | identification. 63 | 64 | (5) Matching of device-specific drivers MUST be based on the textual 65 | manufacturer and product identification in addition to the usual VID/PID 66 | matching. This means that operating system features which are based on 67 | VID/PID matching only (e.g. Windows kernel level drivers, automatic actions 68 | when the device is plugged in etc) MUST NOT be used. The driver matching 69 | MUST be a comparison of the entire strings, NOT a sub-string match. For 70 | CDC-ACM CLASS and MIDI CLASS devices, a generic class driver should be used 71 | and the matching is based on the USB device class. 72 | 73 | (6) The extent to which VID/PID matching is allowed for non device-specific 74 | drivers or features depends on the operating system and particular VID/PID 75 | pair used: 76 | 77 | * Mac OS X, Linux, FreeBSD and other Unixes: No VID/PID matching is 78 | required and hence no VID/PID-only matching is allowed at all. 79 | 80 | * Windows: The operating system performs VID/PID matching for the kernel 81 | level driver. You are REQUIRED to use libusb-win32 (see 82 | http://libusb-win32.sourceforge.net/) as the kernel level driver for 83 | VENDOR CLASS devices. HID CLASS devices all use the generic HID class 84 | driver shipped with Windows, except mice and keyboards. You therefore 85 | MUST NOT use any of the shared VID/PID pairs for mice or keyboards. 86 | CDC-ACM CLASS devices require a ".inf" file which matches on the VID/PID 87 | pair. This ".inf" file MUST load the "usbser" driver to configure the 88 | device as modem (COM-port). 89 | 90 | (7) OBJECTIVE DEVELOPMENT Software GmbH disclaims all liability for any 91 | problems which are caused by the shared use of these VID/PID pairs. You 92 | have been warned that the sharing of VID/PID pairs may cause problems. If 93 | you want to avoid them, get your own VID/PID pair for exclusive use. 94 | 95 | 96 | HOW TO IMPLEMENT THESE RULES 97 | ============================ 98 | 99 | The following rules are for VENDOR CLASS and HID CLASS devices. CDC-ACM 100 | CLASS and MIDI CLASS devices use the operating system's class driver and 101 | don't need a custom driver. 102 | 103 | The host driver MUST iterate over all devices with the given VID/PID 104 | numbers in their device descriptors and query the string representation for 105 | the manufacturer name in USB language 0x0409 (English/US). It MUST compare 106 | the ENTIRE string with your textual manufacturer identification chosen in 107 | (2) above. A substring search for your domain or e-mail address is NOT 108 | acceptable. The driver MUST NOT touch the device (other than querying the 109 | descriptors) unless the strings match. 110 | 111 | For all USB devices with matching VID/PID and textual manufacturer 112 | identification, the host driver must query the textual product 113 | identification and string-compare it with the name of the product it can 114 | control. It may only initialize the device if the product matches exactly. 115 | 116 | Objective Development provides examples for these matching rules with the 117 | "PowerSwitch" project (using libusb) and with the "Automator" project 118 | (using Windows calls on Windows and libusb on Unix). 119 | 120 | 121 | Technical Notes: 122 | ================ 123 | 124 | Sharing the same VID/PID pair among devices is possible as long as ALL 125 | drivers which match the VID/PID also perform matching on the textual 126 | identification strings. This is easy on all operating systems except 127 | Windows, since Windows establishes a static connection between the VID/PID 128 | pair and a kernel level driver. All devices with the same VID/PID pair must 129 | therefore use THE SAME kernel level driver. 130 | 131 | We therefore demand that you use libusb-win32 for VENDOR CLASS devices. 132 | This is a generic kernel level driver which allows all types of USB access 133 | for user space applications. This is only a partial solution of the 134 | problem, though, because different device drivers may come with different 135 | versions of libusb-win32 and they may not work with the libusb version of 136 | the respective other driver. You are therefore encouraged to test your 137 | driver against a broad range of libusb-win32 versions. Do not use new 138 | features in new versions, or check for their existence before you use them. 139 | When a new libusb-win32 becomes available, make sure that your driver is 140 | compatible with it. 141 | 142 | For HID CLASS devices it is necessary that all those devices bind to the 143 | same kernel driver: Microsoft's generic USB HID driver. This is true for 144 | all HID devices except those with a specialized driver. Currently, the only 145 | HIDs with specialized drivers are mice and keyboards. You therefore MUST 146 | NOT use a shared VID/PID with mouse and keyboard devices. 147 | 148 | Sharing the same VID/PID among different products is unusual and probably 149 | violates the USB specification. If you do it, you do it at your own risk. 150 | 151 | To avoid possible incompatibilities, we highly recommend that you get your 152 | own VID/PID pair if you intend to sell your product. Objective 153 | Development's commercial licenses for V-USB include a PID for 154 | unrestricted exclusive use. 155 | 156 | -------------------------------------------------------------------------------- /uDMX.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Name: uDMX.c 3 | * Project: Commandline utility for uDMX interface 4 | * Author: Markus Baertschi 5 | * Based on work from: Christian Starkjohann, 2005-01-16 6 | * 7 | * Creation Date: 2005-01-16 8 | * Tabsize: 4 9 | * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH 10 | * License: Proprietary, free under certain conditions. See Documentation. 11 | * This Revision: $Id: uDMX.c,v 1.1.1.1 2006/02/15 17:55:06 cvs Exp $ 12 | */ 13 | 14 | /* 15 | General Description: 16 | This program controls the PowerSwitch USB device from the command line. 17 | It must be linked with libusb, a library for accessing the USB bus from 18 | Linux, FreeBSD, Mac OS X and other Unix operating systems. Libusb can be 19 | obtained from http://libusb.sourceforge.net/. 20 | */ 21 | 22 | #define UDMXVERSION "1.0" 23 | 24 | #define _GNU_SOURCE 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include /* this is libusb, see http://libusb.sourceforge.net/ */ 30 | #include "uDMX_cmds.h" 31 | 32 | #define USBDEV_SHARED_VENDOR 0x16C0 /* Obdev's free shared VID */ 33 | #define USBDEV_SHARED_PRODUCT 0x05DC /* Obdev's free shared PID */ 34 | /* Use obdev's generic shared VID/PID pair and follow the rules outlined 35 | * in firmware/usbdrv/USBID-License.txt. 36 | */ 37 | 38 | int debug = 0; 39 | int verbose = 0; 40 | 41 | static void usage(char *name) { 42 | fprintf(stderr, "usage:\n"); 43 | fprintf(stderr, " %s [-v] [-d] [ ...]\n", name); 44 | fprintf(stderr, " -v verbose, display interesting runtime info\n"); 45 | fprintf(stderr, " -d debug, display debugging info\n"); 46 | fprintf(stderr, " %s -bootloader start bootloader for firmware update\n", name); 47 | } 48 | 49 | static int usbGetStringAscii(usb_dev_handle *dev, int index, int langid, 50 | char *buf, int buflen) { 51 | char buffer[256]; 52 | int rval, i; 53 | 54 | if ((rval = usb_control_msg(dev, USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR, 55 | (USB_DT_STRING << 8) + index, langid, buffer, 56 | sizeof(buffer), 1000)) < 0) 57 | return rval; 58 | if (buffer[1] != USB_DT_STRING) 59 | return 0; 60 | if ((unsigned char)buffer[0] < rval) 61 | rval = (unsigned char)buffer[0]; 62 | rval /= 2; 63 | /* lossy conversion to ISO Latin1 */ 64 | for (i = 1; i < rval; i++) { 65 | if (i > buflen) /* destination buffer overflow */ 66 | break; 67 | buf[i - 1] = buffer[2 * i]; 68 | if (buffer[2 * i + 1] != 0) /* outside of ISO Latin1 range */ 69 | buf[i - 1] = '?'; 70 | } 71 | buf[i - 1] = 0; 72 | return i - 1; 73 | } 74 | 75 | /* 76 | * uDMX uses the free shared default VID/PID. 77 | * To avoid talking to some other device we check the vendor and 78 | * device strings returned. 79 | */ 80 | static usb_dev_handle *findDevice(void) { 81 | struct usb_bus *bus; 82 | struct usb_device *dev; 83 | char string[256]; 84 | int len; 85 | usb_dev_handle *handle = 0; 86 | 87 | usb_find_busses(); 88 | usb_find_devices(); 89 | for (bus = usb_busses; bus; bus = bus->next) { 90 | for (dev = bus->devices; dev; dev = dev->next) { 91 | if (dev->descriptor.idVendor == USBDEV_SHARED_VENDOR && 92 | dev->descriptor.idProduct == USBDEV_SHARED_PRODUCT) { 93 | if (debug) { printf("Found device with %x:%x\n", 94 | USBDEV_SHARED_VENDOR, USBDEV_SHARED_PRODUCT); } 95 | 96 | /* open the device to query strings */ 97 | handle = usb_open(dev); 98 | if (!handle) { 99 | fprintf(stderr, "Warning: cannot open USB device: %s\n", 100 | usb_strerror()); 101 | continue; 102 | } 103 | 104 | /* now find out whether the device actually is a uDMX */ 105 | len = usbGetStringAscii(handle, dev->descriptor.iManufacturer, 106 | 0x0409, string, sizeof(string)); 107 | if (len < 0) { 108 | fprintf(stderr, "warning: cannot query manufacturer for device: %s\n", 109 | usb_strerror()); 110 | goto skipDevice; 111 | } 112 | if (debug) { printf("Device vendor is %s\n",string); } 113 | if (strcmp(string, "www.anyma.ch") != 0) 114 | goto skipDevice; 115 | 116 | len = usbGetStringAscii(handle, dev->descriptor.iProduct, 0x0409, string, sizeof(string)); 117 | if (len < 0) { 118 | fprintf(stderr, "warning: cannot query product for device: %s\n", usb_strerror()); 119 | goto skipDevice; 120 | } 121 | if (debug) { printf("Device product is %s\n",string); } 122 | if (strcmp(string, "uDMX") == 0) 123 | break; 124 | 125 | skipDevice: 126 | usb_close(handle); 127 | handle = NULL; 128 | } 129 | } 130 | if (handle) 131 | break; 132 | } 133 | return handle; 134 | } 135 | 136 | char * read_uDMXrc (char * keyword1, char * keyword2) { 137 | FILE *uDMXrc; 138 | char uDMXrcname[1024]; 139 | char *HOME, *p, *linebuf; 140 | char keyword[1024]; 141 | size_t len = 0; 142 | ssize_t read; 143 | 144 | HOME=getenv("HOME"); 145 | strcpy(uDMXrcname,HOME); 146 | strcat(uDMXrcname,"/.uDMXrc"); 147 | uDMXrc = fopen(uDMXrcname,"r"); 148 | if (! uDMXrc) { 149 | if (debug) { 150 | perror("Opening $HOME/.uDMXrc failed"); 151 | } 152 | return 0; 153 | } 154 | 155 | sprintf(keyword,"%s %s ",keyword1,keyword2); 156 | while ((read = getline(&linebuf, &len, uDMXrc)) != -1) { 157 | linebuf[strlen(linebuf)-1]='\0'; 158 | // printf("Line: '%s', looking for '%s'\n",linebuf,keyword); 159 | if (linebuf[0]=='#') { continue; } 160 | if ((p=strcasestr(linebuf,keyword))!=NULL) { 161 | // printf(">>> Found '%s' in line '%s'\n",keyword,linebuf); 162 | // printf("<<< %ld %ld\n",(linebuf-p)+strlen(keyword),&p); 163 | return p+strlen(keyword); 164 | } 165 | } 166 | fclose(uDMXrc); 167 | return 0; 168 | } 169 | 170 | int main(int argc, char **argv) { 171 | usb_dev_handle *handle = NULL; 172 | char buffer[8]; 173 | char *linebuf, *token; 174 | int i,nBytes; 175 | int arg,val=0,channel=0; 176 | unsigned char values[512]; 177 | usb_set_debug(0); 178 | 179 | /* 180 | * Commandline - simple flags 181 | * 182 | * The argument '-bootloader' als only argument starts the bootloader and exits 183 | * The firmware download is then performed separately with uboot utility 184 | * The flags '-d' and '-v' provide more verbose output 185 | */ 186 | if (argc == 2 && !strcmp(argv[1], "-bootloader")) { 187 | printf("Starting bootloader...\nPlease use the ./uboot utility to " 188 | "update firmware.\n"); 189 | nBytes = usb_control_msg( 190 | handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, 191 | cmd_StartBootloader, 0, 0, buffer, sizeof(buffer), 5000); 192 | exit(0); 193 | } 194 | 195 | for (arg=1; arg512)) { 236 | fprintf(stderr,"Error: Channel '%i' out of range, must be between 1 and 512 !\n",channel); 237 | usage(argv[0]); 238 | exit(1); 239 | } 240 | arg++; 241 | 242 | /* remaining arguments must be value, look them up one by one */ 243 | for (;arg256)) { 253 | fprintf(stderr,"Error: Value '%d' in '%s' out of range, must be 0-255\n",values[val],argv[arg]); 254 | exit(1); 255 | } 256 | val++; 257 | token=strtok(NULL," "); 258 | } 259 | } else { 260 | if (argv[arg][0]=='0') { 261 | values[val++]=0; 262 | } else { 263 | values[val]=atoi(argv[arg]); 264 | if (values[val]==0) { 265 | fprintf(stderr,"Error: Value '%s' not a number or alias\n",argv[arg]); 266 | exit(1); 267 | } 268 | if ((values[val]<0)||(values[val]>256)) { 269 | fprintf(stderr,"Error: Value '%s' out of range, must be 0-255\n",argv[arg]); 270 | exit(1); 271 | } 272 | val++; 273 | } 274 | } 275 | } 276 | 277 | if (val == 1) { 278 | /* Single value = we have a single / pair */ 279 | if (verbose) printf("uDMX: Setting channel %d to %d\n", channel, values[val-1]); 280 | 281 | nBytes = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, 282 | cmd_SetSingleChannel, values[val-1], channel-1, NULL, 0, 1000); 283 | if (nBytes < 0) 284 | fprintf(stderr, "USB error: %s\n", usb_strerror()); 285 | } 286 | if (val > 1) { 287 | /* More than 1 value to set, send the array*/ 288 | if (verbose) { 289 | printf("uDMX: Setting channels %d-%d to", channel, channel + val - 1); 290 | for (i=0; i