These adverts are supporting the forum's costs and the products/services are not endorsed by the forum owners.
First have you tried?
Log in to Search the Forum for help!
Learn more about using FreeStyler at the FreeStyler WIKI HERE
Learn more about DMX in General at The DMX Wiki HERE

if all else fails and you need a fixture consider the fixture building service HERE

DMX values over SendMessage

Discuss the latest developments or get support for them HERE.
Post Reply
sa1n
Knows how to turn Lights ON
Posts: 4
Joined: August 1st, 2013, 8:17 pm

DMX values over SendMessage

Post by sa1n »

Hi there!

I'm looking for a way to send DMX values directly to freestyler, that means just that I want to set an output channel for a specific fixture. I used the code sample above and I currently have the following code:

Code: Select all

        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            byte[] dmx = new byte[] { 255 };

            FsSendMessage fsSend = new FsSendMessage();
            
            //fsSend.SendMessageFunction(2, 1);
            fsSend.SendChMessageFunction(dmx,1);

        }

Code: Select all

using System;
using System.Runtime.InteropServices;

namespace Freestyler.NET.Wrapper
{
    public class FsSendMessage
    {
        //COMPILE AS X86 otherwise pointers need changing
        //For use with WM_COPYDATA and COPYDATASTRUCT
        [DllImport("User32.dll")]
        public static extern int SendMessage(int hWnd, int Msg, int wParam, ref Copydatastruct lParam);
        [DllImport("user32.dll")]
        public static extern int SendMessage(int hWnd, int Msg, int wParam, int LParam);
        [DllImport("user32.dll")]
        static extern int FindWindow(string lpClassName, string lpWindowName);

        private const int WmUser = 0x400;
        private const int WmCopy = 0x4A;



        private int freestylerConnected()
        {
            int ihandle = FindWindow(null, "FS");
            return ihandle;
        }

        private static Int32 VarPtr(object o)
        {
            GCHandle GC = GCHandle.Alloc(o, GCHandleType.Pinned);
            IntPtr ptr = GC.AddrOfPinnedObject();
            GC.Free();
            return ptr.ToInt32();
        }

        public struct Copydatastruct
        {
            public Int32 DwData;
            public Int32 CbData;
            [MarshalAs(UnmanagedType.I4)]
            public Int32 LpData;
        }

        public void SendChMessageFunction(byte[] DMXvalues, int functionCode)
        {

            Copydatastruct cds;
            cds.DwData = functionCode;
            cds.LpData = VarPtr(DMXvalues);
            cds.CbData = DMXvalues.Length;
            int hWnd = freestylerConnected();
            if (hWnd != 0)
            {
                SendMessage(hWnd, WmCopy, 0, ref cds);
            }

        }

        public void SendMessageFunction(int command, int value)
        {

            int iHandle = freestylerConnected();
            if (freestylerConnected() != 0)
            {
                SendMessage(iHandle, WmUser, command, value);
            }
        }
    }
}
Btw. I'm a c# developer. How can I send a dmx command?

Many thanks in advance!


User avatar
Mattotone
Android Dev (Moderator)
Posts: 1238
Joined: July 10th, 2007, 5:30 pm
FreeStyler Version: BETA
I Use FreeStyler for: Just for the Fun of it.

Re: DMX values over SendMessage

Post by Mattotone »

public void SendChMessageFunction(byte[] DMXvalues, int functionCode)
Is the correct method, if your having issues try using the dll file i uploaded.
Ensure you compile your app x86
Freestyler Addons www.120db.uk
Free Dropbox. 2GB account http://db.tt/J4c5G8C
$100 free credit @DigitalOcean Private Server: https://m.do.co/c/5c4a7c7d6693
Freestyler Android App: https://play.google.com/store/apps/deta ... rts.fs1024
sa1n
Knows how to turn Lights ON
Posts: 4
Joined: August 1st, 2013, 8:17 pm

Re: DMX values over SendMessage

Post by sa1n »

Could you give me an example? I.e. send the dmx value 130 on dmx channel 5.

The program works fine with the standard functions.
User avatar
Mattotone
Android Dev (Moderator)
Posts: 1238
Joined: July 10th, 2007, 5:30 pm
FreeStyler Version: BETA
I Use FreeStyler for: Just for the Fun of it.

Re: DMX values over SendMessage

Post by Mattotone »

is your application compiled as x86? The pointers required for dmx values only work when compiled for x86

to set just ch5 i think you need to send an output mask first. should be explained in the tcp/ip pdf in the fs directory.

also you can try this viewtopic.php?f=38&t=5111&start=10#p21032
Freestyler Addons www.120db.uk
Free Dropbox. 2GB account http://db.tt/J4c5G8C
$100 free credit @DigitalOcean Private Server: https://m.do.co/c/5c4a7c7d6693
Freestyler Android App: https://play.google.com/store/apps/deta ... rts.fs1024
sa1n
Knows how to turn Lights ON
Posts: 4
Joined: August 1st, 2013, 8:17 pm

Re: DMX values over SendMessage

Post by sa1n »

Yes, my application is compiled as x86. Is there an example?
User avatar
Mattotone
Android Dev (Moderator)
Posts: 1238
Joined: July 10th, 2007, 5:30 pm
FreeStyler Version: BETA
I Use FreeStyler for: Just for the Fun of it.

Re: DMX values over SendMessage

Post by Mattotone »

:fs:
Freestyler Connection Demo.rar
You do not have the required permissions to view the files attached to this post.
Freestyler Addons www.120db.uk
Free Dropbox. 2GB account http://db.tt/J4c5G8C
$100 free credit @DigitalOcean Private Server: https://m.do.co/c/5c4a7c7d6693
Freestyler Android App: https://play.google.com/store/apps/deta ... rts.fs1024
sa1n
Knows how to turn Lights ON
Posts: 4
Joined: August 1st, 2013, 8:17 pm

Re: DMX values over SendMessage

Post by sa1n »

Wow! That's really great :) Many thanks!
Post Reply

Return to “FreeStyler 3rd Party Addons and utilities”