Sending Art-Net Packages via NBS.UDP_Send

2020-05-08
2021-09-03
  • leonschoeppl - 2020-05-08

    Hey there,

    I'm trying to send Art-Net packages to an ArtNet-DMX-Converter via NBS.UDP_Send to switch between several DMX Channels within one Universe. I use wireshark to check the packets, and seem to be facing two difficulties:
    - all my UDP Packets seem to be within the port range 1740-1743, instead of the 6454 that I fed to myUDP_Send
    - the UDP Packets I am sending cointain a whole lot more data than just the UDP header and what I put into myUDP_Send.pData

    As my CodeSys experience isn't off the charts, I want to ask you guys whether what I'm trying is possible, and if so, how.

    Cheers,
    Leon

     

    Last edit: leonschoeppl 2020-05-09
  • i-campbell

    i-campbell - 2020-05-08

    1740-1743 is the communication ports for the Development system or a HMI, so you would see them even if you had no NBS running.

    You will need instead a UDP_PEER.
    https://help.codesys.com/webapp/2WcJHFNpdguN8FilHzhiwjDereA%2FUDP_Peer;product=NetBaseServices;version=3.5.16.0

    Please also use the SP16 version of the library, it is amazing!

    Let me know if you are still stuck after using UDP_PEER and I'll try to track down an example.

     
    • leonschoeppl - 2020-05-09

      Thanks mate, I'll try going with UDP_Peer next week!

       
    • leonschoeppl - 2020-05-15

      Hey there again!

      I've now tried using myUDP_PEER without success, as it always puts out an Error/ sets xError to TRUE. I could really do with a code example, as the one I used (NetBaseServicesDemo.project from https://help.codesys.com/webapp/090eefOU8ghnTgjp1u-MsUHjdQY%2Ffld-Examples;product=CAA_NetBaseServices;version=3.5.15.0) didn't get me where I wanted.

      Additionally, the project is in version 3.5.13, so is there any way (other than updating the whole thing) for me to use the SP 16 library?

      Thanks in advance and cheers
      Leon

       

      Last edit: leonschoeppl 2020-05-15
  • i-campbell

    i-campbell - 2020-05-15

    Which IEC language would you be most comfortable with?
    Yes, CAA Net Base Service is replaced with Net Base Services and is slightly different.

     
    πŸ‘
    1
    • leonschoeppl - 2020-05-15

      Thanks for your quick answer, I'd prefer ST!

       
    • auto-knowhow - 2021-09-03

      this helped alot. I didnt realize there were two different libraries. Some examples online would have compile errors. I knew it was a library issue but couldnt figure it out until I read this. Your example code is great. Thanks!

       
      πŸ‘
      1
  • i-campbell

    i-campbell - 2020-05-15

    Have a look at this I put together:
    #5 UDP Send and Receive with Net Base Services SP16
    Let me know if it helps you on your way.

    If you ever want to share your ArtNet-DMX-Converter project in forge, I will be happy to answer any questions you might have about that. You can either use iec-snippets if it's small, or add a new project or library (depending how you have packaged it).


    Talk Topic about project #iec-snippets

     
    • leonschoeppl - 2020-06-05

      Sorry for not answering any quicker and thanks a lot for your piece of code!

      I did update the projekt, switched to NBS SP16 and implemented what you sent me, but sadly I still seem unable to achieve the desired results. When using Wireshark to monitor the local Network, not a single UDP message shows up on port 6454. Any more wisdom you could share with me?

      EDIT: I am receiving 'WRONG_CONFIGURATION' errors from both myUDP_Peer and myUDP_Send.

      In case it is relevant, I'm using a PixtendV2, i.e. CodeSys for RaspberryPi!

      Cheers
      Leon

       

      Last edit: leonschoeppl 2020-06-11
  • leonschoeppl - 2020-06-05

    Thanks for the resources you provided!
    About disabling the firewall, are we talking the routers firewall for the network, or is this something host-based to do with CodeSys directly?

    Cheers
    Leon

     
    • dkugler - 2020-06-05

      because I used the winplc I had to switch off the firewall of Windows10 to get the UDP pakets sent and recieved.

       
  • annD

    annD - 2020-06-05

    I am using the OSCAT libraries for sending ArtNet from a PFC200 with Codesys 3.5.16.0 to a simple ArtNet Node from Ulrich Radig. Thats very reliable since years. Here is some code from the early stage - but still working: http://www.oscat.de/community/index.php/topic,880.msg13485.html#msg13485

    All the best,
    annD

     
  • leonschoeppl - 2020-06-11

    UPDATE: Things are starting to look a lot better, as I can now consistently send Art-Net Packets. I'll post the code once I'm happy with it. Thanks a lot to @i-campbell!

     
  • leonschoeppl - 2020-06-12

    This is the code I'll be using:

    PROGRAM PLC_PRG
    VAR
    
        xSend  : BOOL; 
    
        //Settings
        port : UINT := 6454;
        theirIP : NBS.IPv4Address := (ipAddress := 'XXX.XXX.XXX.XXX'); //BOTEX ArtNet-DMX-Converter
        myIP : NBS.IPv4Address := (ipAddress := 'XXX.XXX.XXX.XXX'); //PixTend
        MySendData : ARRAY [0..50] OF BYTE;
        MySendDataReset : ARRAY [0..50] OF BYTE := [16#41,16#72,16#74,16#2D,16#4E,16#65,16#74,16#00,16#00,16#50,
                                               16#00,16#0E,16#39,16#00,16#01,16#00,16#00,16#20,16#00,16#00,
                                               16#00,16#00,16#00,16#00,16#00,16#00,16#00,16#00,16#00,16#00,
                                               16#00,16#00,16#00,16#00,16#00,16#00,16#00,16#00,16#00,16#00,
                                               16#00,16#00,16#00,16#00,16#00,16#00,16#00,16#00,16#00,16#00];
        NumberOfBytesToSend : UDINT := 50;
    
        //Function instantiation
        myUDP_Peer : NBS.UDP_Peer;
        myUDP_Send : NBS.UDP_Send;
        myUDP_Receive : NBS.UDP_Receive;
    
        ChannelOnNumber : INT := 0;
        state : INT := 0; //CASE state
        i : INT; //FOR Counter
    END_VAR
    
    CASE state OF
    0:
        myUDP_Peer(
            xEnable:= TRUE, 
            xBusy=> , 
            xError=> peerErrorBool, 
            eErrorID=> peerErrorId , 
            itfAsyncProperty:= , 
            itfIPAddress:= myIP, 
            uiPort:= port, 
            itfMulticast:= , 
            xActive=> , 
            itfPeer=> 
        );
    
        state := 1;
    
    1: 
        FOR i := 0 TO 50 DO
            MySendData[i] := MySendDataReset[i];
        END_FOR
        i:= 0;
        IF ChannelOnNumber > 0 THEN
            MySendData[ChannelOnNumber+17] := 16#FF;
        END_IF
        state := 2;
    
    2:
    
        myUDP_Send(
            xExecute:= xSend, 
            udiTimeOut:= 100000, // 100 ms timeout
            xDone=> , 
            xBusy=> , 
            xError=> sendErrorBool , 
            eErrorID=> sendErrorId, 
            itfTSNContext:= , 
            itfPeer:= myUDP_Peer.itfPeer, 
            itfIPAddress:= theirIP, 
            uiPort:= port, 
            pData:= ADR(MySendData), 
            udiSize:= MIN(NumberOfBytesToSend,SIZEOF(MySendData)), 
            udiCount=> 
        );
        xSend := NOT xSend;
    
    
    END_CASE
    

    See Attachment for Example WebVisu UI: DropDownMenu changes PLC_PRG.ChannelOnNumber, while the ApplyButton sets PLC_PRG.state to 1.

     

    Last edit: leonschoeppl 2020-06-12

Log in to post a comment.