Arduino EPOS 24/5

OP #3267557
Lesenswert?

Guten Tag,

ich möchte eine Verbindung mit einem Arduino UNO und einem MAXON MOTORS 
Positioning Controller EPOS 24/5  über die serielle Schnittstelle 
herstellen unm damit die Drehgeschwindigkeit regeln.
Hat jemand von euch die Kommunikation schon hergestellt, bzw weiß wo ich 
diese finde oder wie das geht?

Ich habe ein Beispiel für Windows Visual . Jedoch weiß nicht weiß ich 
nicht wie ich das Senden und Lesen der Daten über die serielle 
Schnittstelle richtig übersetzten muss:


aus SerialCtrl.h


BOOL SerialCtrl::Read(char * inputData, const unsigned int & sizeBuffer, 
unsigned long & length)
{
  if (ReadFile(m_portHandle,  // handle of file to read
    inputData,               // handle of file to read
    sizeBuffer,              // number of bytes to read
    &length,                 // pointer to number of bytes read
    NULL) == 0)              // pointer to structure for data
  {
    // AfxMessageBox("Reading of serial communication has problem.");
    return FALSE;
  }
  if (length > 0)
  {
    inputData[length] = NULL; // Assign end flag of message.
    return TRUE;
  }
  return TRUE;
}

BOOL SerialCtrl::Write(const char * outputData, const unsigned int & 
sizeBuffer, unsigned long & length)
{
  if (length > 0)
  {
    if (WriteFile(m_portHandle, // handle to file to write to
      outputData,              // pointer to data to write to file
      sizeBuffer,              // number of bytes to write
      &length,NULL) == 0)      // pointer to number of bytes written
    {
      AfxMessageBox(L"Reading of serial communication has problem.");
      return FALSE;
    }
    return TRUE;
  }
  return FALSE;
}









aus WinBase.h



WriteFile(
    __in        HANDLE hFile,
    __in_bcount_opt(nNumberOfBytesToWrite) LPCVOID lpBuffer,
    __in        DWORD nNumberOfBytesToWrite,
    __out_opt   LPDWORD lpNumberOfBytesWritten,
    __inout_opt LPOVERLAPPED lpOverlapped
    );

WINBASEAPI
BOOL
WINAPI
ReadFile(
    __in        HANDLE hFile,
    __out_bcount_part_opt(nNumberOfBytesToRead, *lpNumberOfBytesRead) 
__out_data_source(FILE) LPVOID lpBuffer,
    __in        DWORD nNumberOfBytesToRead,
    __out_opt   LPDWORD lpNumberOfBytesRead,
    __inout_opt LPOVERLAPPED lpOverlapped
    );

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren