格式化,并新增打印串口发送内容

This commit is contained in:
zhengxuan.zhang
2022-11-22 16:43:31 +08:00
parent 593080a025
commit 341aaa08ff
9 changed files with 766 additions and 125 deletions
+2
View File
@@ -4,3 +4,5 @@
*.licenses
HSI_HexagonMI_EF3/x64/Debug/
.vscode/
HSI_HexagonMI_EF3/obj/
HSI_SEVENOCEAN_EF1_CsTest/bin/
+1 -1
View File
@@ -107,7 +107,7 @@
</Link>
<PostBuildEvent>
<Command>copy "$(TargetDir)$(ProjectName).dll" "$(SolutionDir)HSI_SEVENOCEAN_EF1_CsTest\bin\Debug\HSI.dll"
copy "$(TargetDir)$(ProjectName).dll" "C:\Hexagon\Metus2021\HSI_Sevenocean_EF3.dll"
copy "$(TargetDir)$(ProjectName).dll" "C:\Hexagon\Metus2020R1\HSI_Sevenocean_EF3.dll"
copy "$(TargetDir)$(ProjectName).dll" "E:\HexagonProjects\2022-05-直线电机平台\EF3-Interfac\PcDmis\Base\Interfac\Msi\Hsi\Tools\UsbUtility\HSI_Sevenocean_EF1_WPFTest\bin\x64\Debug\HSI.dll"</Command>
</PostBuildEvent>
<PreBuildEvent>
File diff suppressed because it is too large Load Diff
+21 -1
View File
@@ -312,14 +312,34 @@ public:
HSI_STATUS SetTriggerLight(int triggleNum, int delayLighting, int delayLightBefor, int triggleMode,
double* Intensities);
HSI_STATUS DCCPPStartPoint(double* startPoint);
/**
* \brief 下发触发间距
* \param AxisTypes 轴
* \param eType 等间距或者等时间
* \param lTrigNumber 触发数量
* \param dTrigDis 间距
* \return
*/
HSI_STATUS DCCScanSetData(UINT AxisTypes, HSI_SCAN_MOTION_TYPE eType, UINT lTrigNumber, double* dTrigDis);
HSI_STATUS DCCScanSetDataOld(UINT AxisTypes, HSI_SCAN_MOTION_TYPE eType, UINT lTrigNumber, double* dTrigDis);
/**
* \brief 开始扫描
* \return
*/
HSI_STATUS DCCScanStart();
HSI_STATUS DCCScanStartOld();
/**
* \brief 停止扫描
* \return
*/
HSI_STATUS DCCScanStop();
HSI_STATUS DCCScanStopOld();
HSI_STATUS DCCForLightPlate();
HSI_STATUS IOStep(bool RunSts);
HSI_STATUS IOprogram(byte* SendData, int length);
HSI_STATUS FindOriginTest(bool state);
HSI_STATUS StartPlcJob(int* CamerasDis, int* BinsDis, int SubArea, int filterTime1, int filterTime2,
int pluseSumDis);
HSI_STATUS SendBinResult(int* BinResult);
@@ -4,6 +4,9 @@
#include "CMMIO_SERIAL.H "
#include <string>
using namespace std;
//////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
#define LONG_TIMEOUT 5000
@@ -564,9 +567,11 @@ void CPSerial::OnReceive()
char s[MAX_RECIEVE_BUFFER_SIZE] = {0};
s[1] = '\0';
CurrentPointer = 0;
printf("MAX_RECIEVE_BUFFER_SIZE: %d m_HandShake:%d\n", MAX_RECIEVE_BUFFER_SIZE, m_HandShake);
if (m_HandShake == CS_HANDSHAKE_FOR_TRESASTR_E)
{
int num = ReadPort(s, MAX_RECIEVE_BUFFER_SIZE);
if ((num > 0) && (num < MAX_RECIEVE_BUFFER_SIZE))
{
if (m_IsWrtingData)
@@ -589,12 +594,17 @@ void CPSerial::OnReceive()
else
{
int num = ReadPort(s, m_iRecvCount);
printf("----RECV: %d----\r\n", num);
if ((num > 0) && (num < MAX_RECIEVE_BUFFER_SIZE))
{
// memset(m_RecvData,0,m_iRecvBytes);
memcpy(m_RecvData, s, num);
m_iRecvBytes = num;
m_iRecvState = TRUE;
for (int i = 0; i < num; i++)
{
printf(" %02X ", m_RecvData[i]);
}
}
}
//LineReceive(s, num);
@@ -1266,6 +1276,30 @@ int CPSerial::HexToInt(char* Data, int Bytes)
return (Value);
}
//字节数组转换为16进制字符
CString CPSerial::ToHexStr(const char* pData, int nLen)
{
CString str;
CString strTemp;
for (int i = 0; i < nLen; i++)
{
strTemp.Format(_T(" %02X "), pData[i]);
str += strTemp;
}
return str;
}
//unsigned char CPSerial::HexCharToByte(char ch)
//{
// if ((ch >= '0') && (ch <= '9'))
// return ch - '0';
// if ((ch >= 'A') && (ch <= 'F'))
// return ch - 'A' + 10;
// if ((ch >= 'a') && (ch <= 'f'))
// return ch - 'a' + 10;
// return 0;
//}
/////////////////////////////////////////////////////////////////////////////
// Private functions
@@ -128,6 +128,10 @@ public:
// Convert ascii hex into an int
int HexToInt(char* Data, int Bytes);
//字节数据转换为16进制字符串
CString ToHexStr(const char* pData, int nLen);
DWORD Send(LPCSTR buffer, int l, BOOL needsResponse = FALSE) override;
//virtual DWORD Send(CString what);
+2 -2
View File
@@ -12,5 +12,5 @@
#define HSI_VERSION_REVNUM
#define HSI_VERSION_BUILD_DATE _T(__DATE__ )
#define HSI_VERSION_BUILD_TIME _T(__TIME__ )
#define HSI_FILE_DESCRIPTION "2022.11.07 / 17:44 "
#define HSI_FILE_CSDESCRIPTION _T("2022.11.07 / 17:44 ")
#define HSI_FILE_DESCRIPTION "2022.11.22 / 15:35 "
#define HSI_FILE_CSDESCRIPTION _T("2022.11.22 / 15:35 ")
Binary file not shown.