Hello,
I want to use an arduino UNO to set the velocity at my EPOS 24/5 with the rs232.
Has someone some experience with this positioning controller and can send me an example sketch or just a tip.
The problem is, that ich don't know how to send and read the datas with the rs232. I tried all Serial.write() an .read stuff with no result. The only thing I 've got is the crc16 ccitt calculation.
How do i translate this(example written in Windows Visual) to use it for arduino:
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
);