This commit is contained in:
xin
2025-06-30 15:51:34 +08:00
parent 023dd01e29
commit 978dcf8abf

View File

@ -1,9 +1,13 @@
#include "IS3Comon.h" #include "IS3Comon.h"
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
void delay(int ms){
Sleep(ms);
}
#else #else
void delay(int ms){
usleep(ms * 1000); // Convert milliseconds to microseconds
}
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#ifndef _POSIX_C_SOURCE #ifndef _POSIX_C_SOURCE
@ -16,13 +20,12 @@
unsigned long long get_system_uptime_ms() { unsigned long long get_system_uptime_ms() {
#ifdef _WIN32 #ifdef _WIN32
return GetTickCount64(); return GetTickCount64();
#else #else
struct timespec ts; struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts); clock_gettime(CLOCK_MONOTONIC, &ts);
return (unsigned long long)(ts.tv_sec) * 1000 + ts.tv_nsec / 1000000; return (unsigned long long)(ts.tv_sec) * 1000 + ts.tv_nsec / 1000000;
void Sleep(long ms) {
usleep(ms*1000); // Sleep for 1 millisecond
}
#endif #endif
} }
@ -30,9 +33,7 @@ unsigned long long get_system_uptime_ms() {
void delay(int ms){
Sleep(ms);
}
u_char BufferForRead[10000]; u_char BufferForRead[10000];