Page 1 of 1

TCP Server Client C#

Posted: April 24th, 2010, 11:07 am
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();

Re: TCP Server Client C#

Posted: April 24th, 2010, 2:05 pm
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:

Re: TCP Server Client C#

Posted: April 25th, 2010, 12:29 pm
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++.

Re: TCP Server Client C#

Posted: April 25th, 2010, 1:28 pm
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:

Re: TCP Server Client C#

Posted: April 25th, 2010, 4:35 pm
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.

Re: TCP Server Client C#

Posted: April 25th, 2010, 4:57 pm
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?

Re: TCP Server Client C#

Posted: April 25th, 2010, 7:15 pm
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!

Re: TCP Server Client C#

Posted: April 26th, 2010, 8:03 pm
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 :)

Re: TCP Server Client C#

Posted: April 26th, 2010, 8:34 pm
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!

Re: TCP Server Client C#

Posted: November 17th, 2010, 10:35 pm
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

Re: TCP Server Client C#

Posted: November 18th, 2010, 9:52 pm
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

Re: TCP Server Client C#

Posted: November 24th, 2010, 10:19 pm
by Mattotone
well max byte is 255.
i imagine it will be {70,83,79,68,255,49,0 to 255,0,0}

Re: TCP Server Client C#

Posted: November 30th, 2010, 10:28 pm
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.

Re: TCP Server Client C#

Posted: December 1st, 2010, 9:37 am
by Knight
ah clear, missed the 'split up' part.

Fog level does work. When i send FSOC304100 it sets the level to 39%.

Re: TCP Server Client C#

Posted: December 1st, 2010, 10:32 am
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).

Re: TCP Server Client C#

Posted: February 4th, 2011, 12:17 pm
by LJ_krede.dk

Re: TCP Server Client C#

Posted: December 4th, 2012, 1:16 am
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.

Re: TCP Server Client C#

Posted: December 4th, 2012, 11:05 am
by jg5985
never mind solved the issue just added the following before terminating the executable.

clientStream.Close();
client.Close();

Re: TCP Server Client C#

Posted: July 2nd, 2014, 4:47 am
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 ?

Re: TCP Server Client C#

Posted: July 2nd, 2014, 9:48 pm
by Mattotone
dont think it is reachable.

Re: TCP Server Client C#

Posted: June 15th, 2016, 1:19 pm
by Mitologico
Hello!
How can i read the caption of override buttons using c#?
Thaks!

Re: TCP Server Client C#

Posted: June 15th, 2016, 2:51 pm
by Mitologico
Solved! I used StreamReader object!

Re: TCP Server Client C#

Posted: June 17th, 2016, 11:48 pm
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

Re: TCP Server Client C#

Posted: February 5th, 2018, 3:39 pm
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"