Applied-motion SV7-Q-EE Manual do Utilizador Página 16

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 19
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 15
6/26/2010
9200032a3eSCLCommunicationReferenceManual Page16
‘ next line fixes it
Winsock1.RemoteHost = Winsock1.RemoteHostIP
' first 16 bits of packet are the ID (opcode)
If UBound(udpData) >= 1 Then
packetID = 256 * udpData(0) + udpData(1)
If packetID = 7 then ' SCL response
SCLrx = ""
For n = 2 To UBound(udpData)
SCLrx = SCLrx & Chr(udpData(n))
Next n
MsgBox SCLrx
End If
End If
End Sub
C#.NET
The.NETlanguagesareMicrosoft’smodern,objectorientedWindowsapplicationbuildingtoolsandinclude
robustEthernetsupport.WepresentthisexampleinC#.
Makesureyourprojectincludesthisline,providingaccesstoanEthernetsocket:
using System.Net.Sockets;
Inyourformheaderyoumustdeclarea UdpClientobjectandcreateaninstance,whichcanbedoneinthe
sameline.Thelocalportnumberisincludedinthe“newUdpClient”call.Thisistheportnumberthatwillbe
reservedonthePCforyourapplication.
static UdpClient udpClient = new UdpClient(7777);
Toopentheconnection,invoketheConnectmethod,specifyingthedrive’sIPaddressandportnumber:
udpClient.Connect(“192.168.0.130”, 7775);
Tosend“RV”tothedrive:
//create a string loaded with the SCL command
Byte[] SCLstring = Encoding.ASCII.GetBytes(“RV”);
// create a byte array that will be used for the actual
// transmission
Byte[] sendBytes = new Byte[SCLstring.Length + 3];
// insert opcode (07 is used for all SCL commands)
sendBytes[0] = 0;
sendBytes[1] = 7;
// copy string to the byte array
System.Array.Copy(SCLstring, 0, sendBytes, 2, SCLstring.Length);
// insert terminator
sendBytes[sendBytes.Length - 1] = 13; // CR
// send it to the drive
udpClient.Send(sendBytes, sendBytes.Length);
GettingresponsesbackfromthedriveinC#isamorecomplicatedthanVB6.Youhavetwochoices:pollfora
responseorcreateacallbackfunctionthatwillprovideatruereceiveevent.
Vista de página 15
1 2 ... 11 12 13 14 15 16 17 18 19

Comentários a estes Manuais

Sem comentários