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

TCP Server Client C#

Discuss the latest developments or get support for them HERE.
Post Reply
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.

TCP Server Client C#

Post by Mattotone »

The new version of freestyler 3.3.1 now includes a TCP Server on port 3332.
Full documentation for this and the send message protocol can be found in your FS instalation directory.

Every message sent to be the server must be 9bytes long.
and start with F,S,O,D which converted into bytes is 70,83,79,68

byte 0: “F”
byte 1: “S”
byte 2: “O”
byte 3: “D”
byte 4 and 5 : Command code 2,0 is blackout
byte 6 : button state : 0 or 255 (0 = on release, 255 = on click) or Fader value: 0 to 255 (green rows in the table)
byte 7 and 8 : argument (for later use)

you will notice i have sent the blackout command twice
{70,83,79,68,2,0,255,0,0}
{70,83,79,68,2,0,0,0,0}
FS uses the commands the same as mouse clicks, Click and release. This is useful when using Flash buttons. The text in bold is 255 for click, 0 is for release.



Here is some example code in c# to make FS blackout

Code: Select all

            using System.IO;
            using System.Net;
            using System.Net.Sockets;

            TcpClient client = new TcpClient();

            IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse("192.168.2.1"), 3332);

            client.Connect(serverEndPoint);

            NetworkStream clientStream = client.GetStream();

             //F,S,O,D,Blackout,Spare,Click,Spare,Spare
            byte[] buffer =new byte[9] {70,83,79,68,2,0,255,0,0};
            clientStream.Write(buffer, 0, buffer.Length);
            clientStream.Flush();
            //F,S,O,D,Blackout,Spare,Release,Spare,Spare
            byte[] buffer2 = new byte[9] { 70, 83, 79, 68, 2, 0, 0, 0, 0 };
            clientStream.Write(buffer2, 0, buffer2.Length);
            clientStream.Flush();


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
User avatar
Shannon D
FS is my life
Posts: 324
Joined: April 10th, 2008, 10:26 pm
FreeStyler Version: 3.3.2
I Use FreeStyler for: Band

Re: TCP Server Client C#

Post by Shannon D »

Dang Matt, Your pretty deep into this. Do you actually get to hook up lights and play once and a while? :lol:

Can you describe some benefits of learning and using TCP Server Client C# :?: I'm clueless :? :lol:
Onge

Re: TCP Server Client C#

Post by Onge »

@Mattone,

Nice work man.
It is something I have got to get into is C# and C++.
Any recommendations on learning material for C# as I think this would possibly be the easier path to take as most C++ stuff seems "DOS" based and does not really go into learning it by using Visual C++.
User avatar
Shannon D
FS is my life
Posts: 324
Joined: April 10th, 2008, 10:26 pm
FreeStyler Version: 3.3.2
I Use FreeStyler for: Band

Re: TCP Server Client C#

Post by Shannon D »

:shock: So you don't want to talk to me, huh? Well fine then, maybe someone else will explain it to me. Come to think of it, my plate is already full, I don't have time to learn new $h^t anyways. My lights work, I don't need that crap...

I gotta get back on the search for Mavi, Lee, arse, jugernaut, astronaut, TWAT NAV, Adam and his flat. :arrow:
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: TCP Server Client C#

Post by Mattotone »

hi guys,
C# was the easiest language for me to pick up as i did java at uni, and c# iv very similar. Not been in the industry i don't know which is more commonly used.
However c++ is a harder language to learn but has a lot more functionality to do with lower level coding, things to do with the operating system and networking.
The things i deal with are much much higher up in the modal. If i need to deal with networking there are things built into c# which deal with it for me.
If you have ever played with VB then Java or c# is probably the next logical step for the tinkerer like me. c# has better integration with an OS and a fantastic development environment, but java is OS independent and can run on android but requires the user to download a run time environment.

The benefits of which will allow you to make simple or even complex applications, it probably wont help create better lighting shows, but is fun to learn and make your own utility s.

The book i used for learning java from was called blue-jay, its designed for the beginner has every thing you need on a disk including an IDE developed for beginners, there are pleanty of tutorials for c# on the net and the microsoft IDE is free and fantastic.
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
User avatar
Shannon D
FS is my life
Posts: 324
Joined: April 10th, 2008, 10:26 pm
FreeStyler Version: 3.3.2
I Use FreeStyler for: Band

Re: TCP Server Client C#

Post by Shannon D »

Mattotone wrote:hi guys, ...........................
Huh! :?: :?

All I got out of all that was:

Matt is at Uni with Java and now C# and C++ are with Blue-jay. Who are these people? Are they looking for Adam's flat tire too?
Mavi
LJ
Posts: 267
Joined: March 30th, 2010, 1:19 am
FreeStyler Version: 3.2.8
I Use FreeStyler for: Just for the Fun of it.

Re: TCP Server Client C#

Post by Mavi »

Shannon D wrote:... I gotta get back on the search for Mavi, Lee, arse, jugernaut, astronaut, TWAT NAV, Adam and his flat. :arrow:
LOL That was a good one :)

Mattotone, you are right that c# and java are easier to lern then c++. But every programming language has its advantages and disadvantages. For example think about computing time. There are things that can be done by c++ up to 10 times faster then java for example.

But I do not think it will be important which language you use for your purpose. What realy is important: someone is developing such tools. I do not use them yet but perhapse later :D So thank you!
I know, my english is not the best. If you have any problem to understand you are welcome to give me englisch lessons
Onge

Re: TCP Server Client C#

Post by Onge »

I have not programmed in C#, but have done some tutorial C++ stuff all in a DOS window, no GUI stuff. Can read C++ programs without too much trouble.

I used to program in such languages as BAL (IBMs Basic Assembly Languange), PL/I, Fortran all on IBM 360 Mainframes. I then moved on to the IBM iSeries used to be called AS/400s and wrote in RPG3, RPG4 and later RPG/ILE. All this work was done in usually manufacturing environments, working for companies such as IBM, Pfizer, Phillips, JDA and many others.

Not done a lot of programming on PCs, but used to write programs using Z80 and 68000 assembly language on ZX81, Spectrum and Amiga.

Trying to find a good introduction to C#, that does not go through the normal boring route of "Hello World!" etc. I already have Visual Studio Professional and going to upgrade to the 2010 version sometime. I always get bored of the way most people teach others to program etc. I always find it easier when I am given a real task to achieve and not some silly program that most tutorials give.


I will talk to whomever I can gleam information from, the more the merrier :)
User avatar
dmxlighting
FS is my life
Posts: 1025
Joined: August 11th, 2008, 11:46 pm
FreeStyler Version: beta
I Use FreeStyler for: Where do I start?

Re: TCP Server Client C#

Post by dmxlighting »

Onge wrote:Not done a lot of programming on PCs, but used to write programs using Z80 and 68000 assembly language on ZX81, Spectrum and Amiga.

Showing your age there Andre! I had a zx81 and a 48k zx spectrum! I was about 8 at the time!
Freestyler DMX - Pissing over the competition since 199x
What do you want for free ?

Freelance Lighting Programmer / Sound Engineer / Designer / Installer and General All Round AV Expert
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: TCP Server Client C#

Post by Mattotone »

new byte[9] {70,83,79,68,155,0,255,0,0};

works fine for me. Opend the master intensity and it sets the value to max

new byte[9] {70,83,79,68,155,0,0,0,0};

set it to zero

as for your other question look at commands 319 to 339

you have to send them 1 by 1
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
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: TCP Server Client C#

Post by Mattotone »

never used but imagine it increments the gobo channel value by one ie. 1,2,3,4,5,6 ... 255
where as next gobo selects the next gobo in the fixtures list
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
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: TCP Server Client C#

Post by Mattotone »

well max byte is 255.
i imagine it will be {70,83,79,68,255,49,0 to 255,0,0}
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
Knight
Knows how to turn Lights ON
Posts: 7
Joined: November 27th, 2010, 8:12 am
FreeStyler Version: 3.4.6

Re: TCP Server Client C#

Post by Knight »

Mmax, did you already find out how to send 1@dmx255 or simulair ?

When i see your code i don't understand how you define 1 click.
The table says command 1 = 320
So i guess it has to be:
{70,83,79,68,320,0,255,0,0) // 1 click
{70,83,79,68,320,0,0,0,0) // 1 release

@Mattotone - can you please help me/us out.

Lot off commands do work, but only single line commands like ' select next fixture = 288' or 'Master 100% = 151'.
Still i can't get the commands to work that sends values to channels.

When i open the command line feature in, and i sent i.e command 1, can i actually see the number in the command line ? So does the command line tool get filled with all the commands we send until we cleat it ?
Because i don't see anything happen, but when i set master 100% i see it pop up.
Knight
Knows how to turn Lights ON
Posts: 7
Joined: November 27th, 2010, 8:12 am
FreeStyler Version: 3.4.6

Re: TCP Server Client C#

Post by Knight »

ah clear, missed the 'split up' part.

Fog level does work. When i send FSOC304100 it sets the level to 39%.
Knight
Knows how to turn Lights ON
Posts: 7
Joined: November 27th, 2010, 8:12 am
FreeStyler Version: 3.4.6

Re: TCP Server Client C#

Post by Knight »

It;s the same table you use for byte protocol except there is no need to recalculate.

For example blackout = 002 then you send FSOC002255 (where 255 is click)
In the table it says: Fog level 304 0 to 255 this makes: FSOC304xxx (where xxx= 0-255).
User avatar
LJ_krede.dk
Moderator
Posts: 1028
Joined: October 29th, 2007, 8:01 pm
FreeStyler Version: 3.3.7
I Use FreeStyler for: Where do I start?

Re: TCP Server Client C#

Post by LJ_krede.dk »

/LJ_krede.dk
Aalborg, Denmark
Moderator, Supporter and Bug report manager for the FreeStyler community
Found a bug? Submit a Bug Report
jg5985
Knows how to turn Lights ON
Posts: 8
Joined: February 6th, 2008, 4:09 am
FreeStyler Version: 3.0.1
I Use FreeStyler for: Stage Show

Re: TCP Server Client C#

Post by jg5985 »

How do you tell freestyler your disconnecting and close the connection?
If i close then reopen my sending application the connection )or close and reopen the socket) the connect is refused by freestyler unless i click the disconnect all button first within freestyler.
jg5985
Knows how to turn Lights ON
Posts: 8
Joined: February 6th, 2008, 4:09 am
FreeStyler Version: 3.0.1
I Use FreeStyler for: Stage Show

Re: TCP Server Client C#

Post by jg5985 »

never mind solved the issue just added the following before terminating the executable.

clientStream.Close();
client.Close();
youngkwangk
Knows how to turn Lights ON
Posts: 3
Joined: September 24th, 2012, 8:38 pm
I Use FreeStyler for: Church

Re: TCP Server Client C#

Post by youngkwangk »

Hello I have a question.

I understand that you should split codes greater than 255, but how would you do codes greater than 510.
For example, 595 - submaster list change 1 ?
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: TCP Server Client C#

Post by Mattotone »

dont think it is reachable.
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
Mitologico
Knows how to turn Lights ON
Posts: 3
Joined: June 15th, 2016, 12:02 pm
FreeStyler Version: 3.6.3
I Use FreeStyler for: Stage Show

Re: TCP Server Client C#

Post by Mitologico »

Hello!
How can i read the caption of override buttons using c#?
Thaks!
Mitologico
Knows how to turn Lights ON
Posts: 3
Joined: June 15th, 2016, 12:02 pm
FreeStyler Version: 3.6.3
I Use FreeStyler for: Stage Show

Re: TCP Server Client C#

Post by Mitologico »

Solved! I used StreamReader object!
Mitologico
Knows how to turn Lights ON
Posts: 3
Joined: June 15th, 2016, 12:02 pm
FreeStyler Version: 3.6.3
I Use FreeStyler for: Stage Show

Re: TCP Server Client C#

Post by Mitologico »

In the next relaese can you implement a code for request the override button tab caption? i'm working for a web GUI using jquery and php
MDAR
Knows how to turn Lights ON
Posts: 7
Joined: August 20th, 2015, 6:26 pm
I Use FreeStyler for: Home Lighting Control

Re: TCP Server Client C#

Post by MDAR »

Hi

Just a quick question...

Can someone tell me where i can find the list of TCP/IP command codes.

I've been searching for an hour and can't locate them..

Thanks in advance.

Stuart

Now I feel like a fool...

There was I looking on the website and forums, it never occured to me to look on my own harddrive....

"Full documentation for this and the send message protocol can be found in your FS instalation directory"
Post Reply

Return to “FreeStyler 3rd Party Addons and utilities”