Click here to Skip to main content
15,893,790 members
Home / Discussions / C#
   

C#

 
GeneralRe: Capture console output from DLL in C# Pin
RYU^^29-May-08 13:53
RYU^^29-May-08 13:53 
AnswerRe: Capture console output from DLL in C# Pin
alleyes22-Oct-09 3:08
professionalalleyes22-Oct-09 3:08 
Questionerror "the path format is not supported" HELP! Pin
guitaraddict479128-May-08 15:36
guitaraddict479128-May-08 15:36 
QuestionHow to OVERWRITE the text file instead of appending to it? Pin
Joplinazz28-May-08 14:34
Joplinazz28-May-08 14:34 
AnswerRe: How to OVERWRITE the text file instead of appending to it? Pin
Christian Graus28-May-08 14:39
protectorChristian Graus28-May-08 14:39 
GeneralRe: How to OVERWRITE the text file instead of appending to it? Pin
Joplinazz28-May-08 15:08
Joplinazz28-May-08 15:08 
QuestionAny free (or < $100) obfuscators that will obfuscate mixed mode assemblies? Pin
Member 391904928-May-08 14:30
Member 391904928-May-08 14:30 
AnswerRe: Any free (or < $100) obfuscators that will obfuscate mixed mode assemblies? Pin
leppie28-May-08 21:19
leppie28-May-08 21:19 
GeneralRe: Any free (or < $100) obfuscators that will obfuscate mixed mode assemblies? Pin
Member 391904929-May-08 6:00
Member 391904929-May-08 6:00 
GeneralRe: Any free (or < $100) obfuscators that will obfuscate mixed mode assemblies? Pin
leppie29-May-08 23:59
leppie29-May-08 23:59 
QuestionProblem in viewing pictures on a Win Form Pin
LordCover28-May-08 14:25
LordCover28-May-08 14:25 
AnswerRe: Problem in viewing pictures on a Win Form Pin
Christian Graus28-May-08 14:41
protectorChristian Graus28-May-08 14:41 
GeneralRe: Problem in viewing pictures on a Win Form Pin
LordCover28-May-08 14:52
LordCover28-May-08 14:52 
GeneralRe: Problem in viewing pictures on a Win Form Pin
Christian Graus28-May-08 15:10
protectorChristian Graus28-May-08 15:10 
GeneralRe: Problem in viewing pictures on a Win Form Pin
LordCover28-May-08 15:16
LordCover28-May-08 15:16 
GeneralRe: Problem in viewing pictures on a Win Form Pin
Christian Graus28-May-08 15:23
protectorChristian Graus28-May-08 15:23 
GeneralRe: Problem in viewing pictures on a Win Form Pin
LordCover28-May-08 15:24
LordCover28-May-08 15:24 
QuestionHow to delete memory allocated by COM? Pin
RYU^^28-May-08 13:52
RYU^^28-May-08 13:52 
AnswerRe: How to delete memory allocated by COM? Pin
RYU^^28-May-08 14:34
RYU^^28-May-08 14:34 
AnswerRe: How to delete memory allocated by COM? Pin
Tony Richards29-May-08 3:30
Tony Richards29-May-08 3:30 
GeneralRe: How to delete memory allocated by COM? Pin
RYU^^29-May-08 13:51
RYU^^29-May-08 13:51 
QuestionAbout DMX protocol Pin
pocho210128-May-08 13:24
pocho210128-May-08 13:24 
AnswerRe: About DMX protocol Pin
Vasudevan Deepak Kumar28-May-08 18:31
Vasudevan Deepak Kumar28-May-08 18:31 
AnswerRe: About DMX protocol [modified] Pin
muzes24-Sep-09 11:37
muzes24-Sep-09 11:37 
The DMX software protocol is described here:

http://www.theater-technisch-lab.nl/dmxen.htm

RS-485 is not actually a protocol but a hardware interface.
It transmits data as the voltage difference between two data lines, rather than the absolute voltage on a single data line. Software wise, it is exactly like RS-232 but its maximum cable length is much further (roughly 1000M vs 12M).

In other words, for DMX you cannot use your serial port, have to spend money on hardware. The cheapest I have found is the Enttec Open DMX controller. (USD) $60.


If you are writing your own code this guy, Hippy, is a great start.

http://members.westnet.com.au/rowanmac/opendmx.html

He has an open source VB that shows how to write to the controller.

One thing to watch out for is installing the driver for the controller.
The included driver did not work for me on WinXP.
But the following did:

http://www.enttec.com/dmx_usb/d2xx_setup.exe

Here is a quick and dirty C# class to run the Enttec OpenDmx usb controller:



using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Threading;


namespace Test
{

public class OpenDMX

{

public static byte[] buffer;
public static uint handle;
public static bool done = false;
public static int bytesWritten = 0;
public static FT_STATUS status;

public const byte BITS_8 = 8;
public const byte STOP_BITS_2 = 2;
public const byte PARITY_NONE = 0;
public const UInt16 FLOW_NONE = 0;
public const byte PURGE_RX = 1;
public const byte PURGE_TX = 2;




[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_Open(UInt32 uiPort, ref uint ftHandle);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_Close(uint ftHandle);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_Read(uint ftHandle, IntPtr lpBuffer, UInt32 dwBytesToRead, ref UInt32 lpdwBytesReturned);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_Write(uint ftHandle, IntPtr lpBuffer, UInt32 dwBytesToRead, ref UInt32 lpdwBytesWritten);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_SetDataCharacteristics(uint ftHandle, byte uWordLength, byte uStopBits, byte uParity);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_SetFlowControl(uint ftHandle, char usFlowControl, byte uXon, byte uXoff);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_GetModemStatus(uint ftHandle, ref UInt32 lpdwModemStatus);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_Purge(uint ftHandle, UInt32 dwMask);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_SetBreakOn(uint ftHandle);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_SetBreakOff(uint ftHandle);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_GetStatus(uint ftHandle, ref UInt32 lpdwAmountInRxQueue, ref UInt32 lpdwAmountInTxQueue, ref UInt32 lpdwEventStatus);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_ResetDevice(uint ftHandle);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_SetDivisor(uint ftHandle, char usDivisor);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_ClrRts(uint ftHandle);




public static void start()
{
buffer = new byte[4]; // can be any length up to 512. The shorter the faster.
handle = 0;
status = FT_Open(0, ref handle);
Thread thread = new Thread(new ThreadStart(writeData));
thread.Start();
setDmxValue(1, 0); // set DMX channel 1 to maximum value
}

public static void setDmxValue(int channel, byte value)
{
buffer[channel]=value;
}

public static void writeData()
{
while (!done)
{
initOpenDMX();
FT_SetBreakOn(handle);
FT_SetBreakOff(handle);
bytesWritten = write(handle, buffer, buffer.Length);
System.Threading.Thread.Sleep(50);
}

}

public static int write(uint handle, byte[] data, int length)
{
IntPtr ptr = Marshal.AllocHGlobal((int)length);
Marshal.Copy(data, 0, ptr, (int)length);
uint bytesWritten = 0;
FT_Write(handle, ptr, (uint)length, ref bytesWritten);
return (int)bytesWritten;
}

public static void initOpenDMX()
{
status = FT_ResetDevice(handle);
status = FT_SetDivisor(handle, (char)12); // set baud rate
status = FT_SetDataCharacteristics(handle, BITS_8, STOP_BITS_2, PARITY_NONE);
status = FT_SetFlowControl(handle, (char)FLOW_NONE, 0, 0);
status = FT_ClrRts(handle);
status = FT_Purge(handle, PURGE_TX);
status = FT_Purge(handle, PURGE_RX);
}

}


public enum FT_STATUS2
{
FT_OK = 0,
FT_INVALID_HANDLE,
FT_DEVICE_NOT_FOUND,
FT_DEVICE_NOT_OPENED,
FT_IO_ERROR,
FT_INSUFFICIENT_RESOURCES,
FT_INVALID_PARAMETER,
FT_INVALID_BAUD_RATE,
FT_DEVICE_NOT_OPENED_FOR_ERASE,
FT_DEVICE_NOT_OPENED_FOR_WRITE,
FT_FAILED_TO_WRITE_DEVICE,
FT_EEPROM_READ_FAILED,
FT_EEPROM_WRITE_FAILED,
FT_EEPROM_ERASE_FAILED,
FT_EEPROM_NOT_PRESENT,
FT_EEPROM_NOT_PROGRAMMED,
FT_INVALID_ARGS,
FT_OTHER_ERROR
};

}

modified on Thursday, September 24, 2009 6:54 PM

Questionprogress bar is hanging Pin
Genius.Boy28-May-08 12:54
Genius.Boy28-May-08 12:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.