diff --git a/contrib/samples/samples/win32/mfc/CanalDiagnostic/CanalDiagnosticDoc.h b/contrib/samples/samples/win32/mfc/CanalDiagnostic/CanalDiagnosticDoc.h index 76cdd4890..575cadfdc 100644 --- a/contrib/samples/samples/win32/mfc/CanalDiagnostic/CanalDiagnosticDoc.h +++ b/contrib/samples/samples/win32/mfc/CanalDiagnostic/CanalDiagnosticDoc.h @@ -26,8 +26,8 @@ // $Revision: 1.3 $ ///////////////////////////////////////////////////////////////////////////// -#if !defined(AFX_CANALDIAGNOSTICDOC_H__73D0D1F3_987B_4A42_ADD5_AE5718C9D792__INCLUDED_) -#define AFX_CANALDIAGNOSTICDOC_H__73D0D1F3_987B_4A42_ADD5_AE5718C9D792__INCLUDED_ +#if !defined(CANALDIAGNOSTICDOC_H__73D0D1F3_987B_4A42_ADD5_AE5718C9D792__INCLUDED_) +#define CANALDIAGNOSTICDOC_H__73D0D1F3_987B_4A42_ADD5_AE5718C9D792__INCLUDED_ #if _MSC_VER > 1000 #pragma once @@ -152,7 +152,5 @@ class CCanalDiagnosticDoc : public CDocument ///////////////////////////////////////////////////////////////////////////// -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. -#endif // !defined(AFX_CANALDIAGNOSTICDOC_H__73D0D1F3_987B_4A42_ADD5_AE5718C9D792__INCLUDED_) +#endif // !defined(CANALDIAGNOSTICDOC_H__73D0D1F3_987B_4A42_ADD5_AE5718C9D792__INCLUDED_) diff --git a/contrib/samples/samples/win32/mfc/CanalDiagnostic/SendBurst.cpp b/contrib/samples/samples/win32/mfc/CanalDiagnostic/SendBurst.cpp index 2a47bdd5f..d734df0cc 100644 --- a/contrib/samples/samples/win32/mfc/CanalDiagnostic/SendBurst.cpp +++ b/contrib/samples/samples/win32/mfc/CanalDiagnostic/SendBurst.cpp @@ -8,7 +8,7 @@ // // This file is part of the CANAL (https://www.vscp.org) // -// Copyright (C) 2000-2025 Ake Hedman, eurosource, +// Copyright (C) 2000-2025 Ake Hedman, D of Scandinavia, // // This file is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/contrib/samples/samples/win32/mfc/CanalDiagnostic/SendBurst.h b/contrib/samples/samples/win32/mfc/CanalDiagnostic/SendBurst.h index 2665b43d0..4bd0f3c11 100644 --- a/contrib/samples/samples/win32/mfc/CanalDiagnostic/SendBurst.h +++ b/contrib/samples/samples/win32/mfc/CanalDiagnostic/SendBurst.h @@ -7,7 +7,7 @@ // // This file is part of the CANAL (https://www.vscp.org) // -// Copyright (C) 2000-2025 Ake Hedman, eurosource, +// Copyright (C) 2000-2025 Ake Hedman, D of Scandinavia, // // This file is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/contrib/samples/samples/win32/mfc/README b/contrib/samples/samples/win32/mfc/README index cac9bd81b..64948b19d 100644 --- a/contrib/samples/samples/win32/mfc/README +++ b/contrib/samples/samples/win32/mfc/README @@ -1,3 +1,15 @@ +VSCP Simple Button +================== +Application that show how to build a small Visual C++ application that send events through +the daemon interface. + + +VSCP Simple Lamp +================ +Application that show how to build a small Visual C++ application that receive events through +the daemon interface. + + CanalDiagnostic =============== This was the first general message hadnling app for CANAL and was written using MFC. diff --git a/contrib/samples/samples/win32/mfc/loggerwnd/loggerwnd.h b/contrib/samples/samples/win32/mfc/loggerwnd/loggerwnd.h index ebe4a3c20..476583650 100644 --- a/contrib/samples/samples/win32/mfc/loggerwnd/loggerwnd.h +++ b/contrib/samples/samples/win32/mfc/loggerwnd/loggerwnd.h @@ -42,5 +42,7 @@ class CLoggerWndApp : public CWinApp ///////////////////////////////////////////////////////////////////////////// +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(LOGGERWND_H__B38025D1_B5E4_4E4F_91E3_2AA787075D4C__INCLUDED_) diff --git a/src/vscp/common/vscp-bootdevice-pic1.cpp b/src/vscp/common/vscp-bootdevice-pic1.cpp index 1f235c7bf..64c46e3e4 100644 --- a/src/vscp/common/vscp-bootdevice-pic1.cpp +++ b/src/vscp/common/vscp-bootdevice-pic1.cpp @@ -757,7 +757,7 @@ CBootDevice_PIC1::writeFirmwareSector(uint8_t *paddr) // Put data into frame for (int i = 0; i < 8; i++) { - msg.data[i + offset] = paddr[i]; + msg.data[i] = paddr[i]; m_checksum += paddr[i]; }; diff --git a/src/vscp/common/vscp-client-canal.cpp b/src/vscp/common/vscp-client-canal.cpp index 5e9b41a07..ae9a24d46 100644 --- a/src/vscp/common/vscp-client-canal.cpp +++ b/src/vscp/common/vscp-client-canal.cpp @@ -68,8 +68,12 @@ vscpClientCanal::vscpClientCanal() pthread_mutex_init(&m_mutexif, NULL); pthread_mutex_init(&m_mutexReceiveQueue, NULL); - // sem_init(&m_semSendQueue, 0, 0); +// sem_init(&m_semSendQueue, 0, 0); +#ifdef WIN32 + m_semReceiveQueue = CreateSemaphore(NULL, 0, 0x7fffffff, NULL); +#else sem_init(&m_semReceiveQueue, 0, 0); +#endif // pthread_mutex_init(&m_mutexSendQueue, NULL); pthread_mutex_init(&m_mutexReceiveQueue, NULL); @@ -85,16 +89,20 @@ vscpClientCanal::~vscpClientCanal() { disconnect(); +#ifdef WIN32 + CloseHandle(m_semReceiveQueue); +#else sem_destroy(&m_semReceiveQueue); +#endif pthread_mutex_destroy(&m_mutexif); pthread_mutex_destroy(&m_mutexReceiveQueue); // Clear the input queue (if needed) while (m_receiveQueue.size()) { - vscpEvent *pev = m_receiveQueue.front(); - m_receiveQueue.pop_front(); - vscp_deleteEvent(pev); + vscpEvent *pev = m_receiveQueue.front(); + m_receiveQueue.pop_front(); + vscp_deleteEvent(pev); } spdlog::trace("CANAL CLIENT: destructor vscp_client_canal object."); @@ -660,8 +668,6 @@ workerThread(void *pObj) // while (cnt) { - - if (CANAL_ERROR_SUCCESS == pClient->m_canalif.CanalBlockingReceive(&msg, 100)) { spdlog::trace("CANAL CLIENT: workthread. Event received"); diff --git a/src/vscp/common/vscp-client-tcp.cpp b/src/vscp/common/vscp-client-tcp.cpp index a1fff5e08..e80358cff 100644 --- a/src/vscp/common/vscp-client-tcp.cpp +++ b/src/vscp/common/vscp-client-tcp.cpp @@ -52,7 +52,11 @@ vscpClientTcp::vscpClientTcp() vscp_clearVSCPFilter(&m_filterIn); // Accept all events vscp_clearVSCPFilter(&m_filterOut); // Send all events +#ifdef WIN32 + m_semReceiveQueue = CreateSemaphore(NULL, 0, 0x7fffffff, NULL); +#else sem_init(&m_semReceiveQueue, 0, 0); +#endif pthread_mutex_init(&m_mutexTcpIpObject, NULL); pthread_mutex_init(&m_mutexReceiveQueue, NULL); @@ -67,16 +71,20 @@ vscpClientTcp::~vscpClientTcp() // Just to be sure disconnect(); +#ifdef WIN32 + CloseHandle(m_semReceiveQueue); +#else sem_destroy(&m_semReceiveQueue); +#endif pthread_mutex_destroy(&m_mutexTcpIpObject); pthread_mutex_destroy(&m_mutexReceiveQueue); // Clear the input queue (if needed) while (m_receiveList.size()) { - vscpEvent *pev = m_receiveList.front(); - m_receiveList.pop_front(); - vscp_deleteEvent(pev); + vscpEvent *pev = m_receiveList.front(); + m_receiveList.pop_front(); + vscp_deleteEvent(pev); } } diff --git a/src/vscp/common/vscpremotetcpif.cpp b/src/vscp/common/vscpremotetcpif.cpp index ce99c10ad..7502e1d01 100644 --- a/src/vscp/common/vscpremotetcpif.cpp +++ b/src/vscp/common/vscpremotetcpif.cpp @@ -743,7 +743,7 @@ VscpRemoteTcpIf::doCmdReceiveEx(vscpEventEx *pEventEx) } if (!m_inputStrArray.size()) { - return VSCP_ERROR_ERROR; + return VSCP_ERROR_RCV_EMPTY; } vscpEvent *pEvent = new vscpEvent;