Wake On Lan

Charles LawCharles Law Junior MemberPosts: 72
Does anybody try to switch on a PC through Wake On LAN using NI Controller?
:p:p:p

Comments

  • SendStringSendString Junior Member Posts: 19
    Try this:

    Try this, it works:
    PROGRAM_NAME='WakeOnLan,Rev 0' 
    
    DEFINE_DEVICE
    TP=10001:1:0
    
    DEFINE_VARIABLE
    
    slong Result   // if 0 then Port opened
    integer connected
    MAC[6]             // MAC-Adress of the Computers Network-card (6 Bytes)
    START[6]          // 6 x $FF, Part of the 'Magic Packet'
    
    DEFINE_START
    
    MAC="$00,$B0,$D0,$A0,$C2,$DE"  //Example
    START="$FF,$FF,$FF,$FF,$FF,$FF"
    Result=99
    
    DEFINE_PROGRAM 
    
    Push[tp,1]
    {   
      Result=IP_CLIENT_OPEN (2,'255.255.255.255', 2304, 2)  // Open port with Broadcast adress and Port=2304 , UDP
       if(result=0)
       {      
          connected=1
          result=99      
       }   
    }
     Push[tp,2]
    {   
       IP_SERVER_CLOSE (2)   
       connected=0
    }   
    Push[tp,3]    // Magic Packet: 6 x $FF, 16 x Mac-Adress
    {
       send_string 0:2:1,"START,MAC,MAC,MAC,MAC,MAC,MAC,MAC,MAC,MAC,MAC,MAC,MAC,MAC,MAC,MAC,MAC"   }
    
    [tp,1]=connected
    [tp,2]=(!connected)
    
  • Charles LawCharles Law Junior Member Posts: 72
    Thanks for help.
    :):):)
  • I created a module for this a while ago.
    Please try it....

    Regards, Leon
  • Charles LawCharles Law Junior Member Posts: 72
    Leon,

    Thanks for sharing.

    Cheers,
    Charles
  • adamjbadamjb Junior Member Posts: 4
    Sorry I never responded to say thanks for the help it was greatly appreciated.
    Adam
  • johnzacjohnzac Junior Member Posts: 4
    Hello

    I have a VDR (Reelbox) with the MAC Aresse: 00-1B-73-71-64-58

    Is it really MAC = "$00,$1B,$73, $71, $64, $58"

    Unfortunately does not work

    From the computer works with Windows 00-1B-73-71-64-58 (program WAKEON)

    Thank you
  • bobbob Independent Programmer Posts: 296
    Interesting, when I use the straight command it works but doesn't when use I the supplied module from Leon.
  • smckintysmckinty Junior Member Posts: 7
    I had issues using MAC addresses from a string (eg sMACaddress = '01A623B745C8'), then discovered that if I converted each hex set to an integer using HEXTOI, I could send them instead, after recombining them into a single string:

    (Based on the MAC above)
    nHexToNumber[1] = HEXTOI('01')
    nHexToNumber[2] = HEXTOI('A6')
    .
    .
    nHexToNumber[6] = HEXTOI('C8')

    sParsedMACAddress = "nHexToNumber[1],nHexToNumber[2],nHexToNumber[3],
    nHexToNumber[4],nHexToNumber[5],nHexToNumber[6]"

    SEND_STRING 0:2:0,"START,sParsedMACAddress,sParsedMACAddress,
    sParsedMACAddress,sParsedMACAddress,sParsedMACAddress,sParsedMACAddress,
    sParsedMACAddress,sParsedMACAddress,sParsedMACAddress,sParsedMACAddress,
    sParsedMACAddress,sParsedMACAddress,sParsedMACAddress,sParsedMACAddress,
    sParsedMACAddress,sParsedMACAddress"

    As far as I can tell, the problem was that as a string, each hex set ('01', 'A6', etc) is treated as 2 bytes ('0'+'1', 'A'+'6"...) giving 12 in total, but the MAC address can only be 6. By converting to an integer, each number is sent as a single byte (MAC above translates to 1, 166, 35, 183, 69, 200)


    At least, that's my understanding of it all - happy to get further clarification.

    May not be the cleanest way to do it - but at least I know it works!
  • Sendstring's method works for me in 2019, long live netlinx

    changed port to port 9 for my network though !

Sign In or Register to comment.