Skip to content

Commit ce58bb4

Browse files
committed
windows and linux emulator changes
1 parent d568f92 commit ce58bb4

6 files changed

Lines changed: 49 additions & 15 deletions

File tree

uCNC/src/hal/mcus/virtual/mcu_virtual.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ extern "C"
353353
#endif
354354

355355
#if defined(MCU_HAS_ONESHOT_TIMER)
356-
MCU_CALLBACK mcu_timeout_delgate mcu_timeout_cb = NULL;
356+
extern MCU_CALLBACK mcu_timeout_delgate mcu_timeout_cb;
357357
static uint32_t virtual_oneshot_counter;
358358
static FORCEINLINE void mcu_gen_oneshot(void)
359359
{

uCNC/src/hal/mcus/virtual/mcu_virtual.dev

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ IncludeVersionInfo=0
2929
SupportXPThemes=0
3030
CompilerSet=1
3131
CompilerSettings=10000000a0000000001000000
32-
UnitCount=114
32+
UnitCount=115
3333

3434
[VersionInfo]
3535
Major=1
@@ -1190,3 +1190,13 @@ Priority=1000
11901190
OverrideBuildCmd=0
11911191
BuildCmd=
11921192

1193+
[Unit115]
1194+
FileName=virtual_windows.c
1195+
CompileCpp=0
1196+
Folder=
1197+
Compile=1
1198+
Link=1
1199+
Priority=1000
1200+
OverrideBuildCmd=0
1201+
BuildCmd=
1202+

uCNC/src/hal/mcus/virtual/mcumap_virtual.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#define MCU_WEAK __attribute__((weak, weakref))
4040

4141
/* 7.18.2.1 Limits of exact-width integer types */
42+
#ifndef INT8_MIN
4243
#define INT8_MIN (-128)
4344
#define INT16_MIN (-32768)
4445
#define INT32_MIN (-2147483647 - 1)
@@ -53,6 +54,7 @@
5354
#define UINT16_MAX 65535
5455
#define UINT32_MAX 0xffffffffU /* 4294967295U */
5556
#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */
57+
#endif
5658

5759
// needed by software delays
5860
#ifndef MCU_CLOCKS_PER_CYCLE
@@ -65,9 +67,13 @@
6567
#define MCU_CYCLES_PER_LOOP_OVERHEAD 0
6668
#endif
6769

68-
#define MCU_HAS_UART
70+
// #define MCU_HAS_UART
6971
#ifndef UART_PORT_NAME
72+
#ifndef __unix__
7073
#define UART_PORT_NAME "\\\\.\\COM14"
74+
#else
75+
#define UART_PORT_NAME "/dev/ttyS0"
76+
#endif
7177
#endif
7278

7379
#define MCU_HAS_UART2
@@ -520,4 +526,10 @@ extern const tool_t vfd_pwm;
520526

521527
#define asm __asm__
522528

529+
// #ifdef __unix__
530+
// // #ifndef sqrtf
531+
// // #define sqrtf sqrt
532+
// // #endif
533+
// #endif
534+
523535
#endif

uCNC/src/hal/mcus/virtual/virtual.ini

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,31 @@ extra_scripts = uCNC/src/hal/mcus/virtual/win_compiler.py
2424
[env:EMULATOR_LINUX]
2525
platform = native
2626
framework =
27-
platform_packages = platformio/linux_x86_64
28-
; build_src_filter =
29-
; +<*>
27+
; platform_packages = platformio/linux_x86_64@^1.2.0
28+
build_src_filter =
29+
+<*>
30+
-<src/hal/mcus/avr>
31+
-<src/hal/mcus/esp32>
32+
-<src/hal/mcus/esp32c3>
33+
-<src/hal/mcus/esp32s3>
34+
-<src/hal/mcus/esp32common>
35+
-<src/hal/mcus/esp8266>
36+
-<src/hal/mcus/lpc176x>
37+
-<src/hal/mcus/rp2040>
38+
-<src/hal/mcus/rp2350>
39+
-<src/hal/mcus/stm32f0x>
40+
-<src/hal/mcus/stm32f1x>
41+
-<src/hal/mcus/stm32f4x>
42+
-<src/hal/mcus/stm32h7x>
3043
; +<../makefiles/virtual/>
3144
; -<src/tinyusb>
32-
; -<src/hal/mcus/avr>
45+
; -<src/hal/mcus/avr>
3346
; -<../makefiles/virtual/clib>
3447
debug_tool = native
3548
build_type = debug
3649
debug_build_flags = -Og -g3
3750
debug_init_cmds =
3851
run
39-
build_flags = ${env.build_flags} -std=gnu99 -Wall -fdata-sections -ffunction-sections -fno-exceptions -Wl,--gc-sections -D MCU=MCU_VIRTUAL_LINUX -D BOARD=BOARD_CUSTOM -g -O0
52+
build_flags = ${env.build_flags} -std=gnu99 -Wall -fdata-sections -ffunction-sections -fno-exceptions -Wl,--gc-sections -D MCU=MCU_VIRTUAL_LINUX -D BOARD=BOARD_CUSTOM -lm -g -O0
4053
; -D WIN_COM_NAME=COM1 -D SOCKET_PORT=34000 -lws2_32
4154
; extra_scripts = uCNC/src/hal/mcus/virtual/win_compiler.py

uCNC/src/hal/mcus/virtual/virtual_linux.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ typedef struct serial_port_
6666
serial_port_t g_uart = {0};
6767

6868
/* Forward declarations for callbacks referenced in ioserver code */
69-
extern VIRTUAL_MAP virtualmap;
7069
extern void mcu_limits_changed_cb(void);
7170
extern void mcu_probe_changed_cb(void);
7271
extern void mcu_controls_changed_cb(void);
@@ -267,7 +266,7 @@ void *ioserver(void *args)
267266
/* Ensure old socket removed */
268267
unlink(UCNCCIO_SOCKET_PATH);
269268

270-
server_fd = socket(AF_UNIX, SOCK_STREAM, 0);
269+
server_fd = socket(AF_UNIX, 1, 0);
271270
if (server_fd < 0)
272271
{
273272
perror("Create socket failed");
@@ -638,7 +637,7 @@ void get_current_dir(char *cwd, size_t len)
638637

639638
#if defined(ENABLE_SOCKETS)
640639

641-
typedef int socklen_t;
640+
// typedef int socklen_t;
642641

643642
/* socket_init: nothing to do on Linux; return 0 on success */
644643
int socket_init(void)

uCNC/src/modules/net/socket.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@ void socket_server_dotasks(void)
273273
{
274274
remove_client(socket, c);
275275
}
276-
else if (errno != EAGAIN && errno != EWOULDBLOCK)
277-
{
278-
remove_client(socket, c);
279-
}
276+
// else if (errno != EAGAIN && errno != EWOULDBLOCK)
277+
// {
278+
// remove_client(socket, c);
279+
// }
280280
else
281281
{
282282
if (socket->client_onidle_cb)

0 commit comments

Comments
 (0)