feat: 使用netsh指令设置arp

This commit is contained in:
alivender
2025-07-18 14:37:25 +08:00
parent 35bad4027d
commit ba79a2093b
5 changed files with 179 additions and 66 deletions

View File

@@ -8,11 +8,11 @@ static class CameraAddr
{
public const UInt32 BASE = 0x7000_0000;
public const UInt32 STORE_ADDR = BASE + 0x12;
public const UInt32 STORE_NUM = BASE + 0x13;
public const UInt32 EXPECTED_VH = BASE + 0x14;
public const UInt32 CAPTURE_ON = BASE + 0x15;
public const UInt32 CAMERA_POWER = BASE + 0x16; //[0]: rstn, 0 is reset. [8]: power down, 1 is down.
public const UInt32 DMA0_START_WRITE_ADDR = BASE + 0x0C;
public const UInt32 DMA0_END_WRITE_ADDR = BASE + 0x0D;
public const UInt32 DMA0_CAPTURE_CTRL = BASE + 0x0E; //[0]: on, 1 is on. [8]: reset, 1 is reset.
public const UInt32 EXPECTED_VH = BASE + 0x0F;
public const UInt32 CAMERA_POWER = BASE + 0x10; //[0]: rstn, 0 is reset. [8]: power down, 1 is down.
}
class Camera
@@ -156,7 +156,7 @@ class Camera
public async ValueTask<Result<bool>> EnableHardwareTrans(bool isEnable)
{
var ret = await UDPClientPool.WriteAddr(this.ep, this.taskID, CameraAddr.CAPTURE_ON, Convert.ToUInt32(isEnable));
var ret = await UDPClientPool.WriteAddr(this.ep, this.taskID, CameraAddr.DMA0_CAPTURE_CTRL, (isEnable ? 0x00000001u : 0x00000100u));
if (!ret.IsSuccessful)
{
logger.Error($"Failed to write CAPTURE_ON to camera at {this.address}:{this.port}, error: {ret.Error}");
@@ -361,7 +361,7 @@ class Camera
// 1. 配置UDP相关寄存器
{
var ret = await UDPClientPool.WriteAddr(this.ep, this.taskID, CameraAddr.STORE_ADDR, FrameAddr);
var ret = await UDPClientPool.WriteAddr(this.ep, this.taskID, CameraAddr.DMA0_START_WRITE_ADDR, FrameAddr);
if (!ret.IsSuccessful)
{
logger.Error($"Failed to write STORE_ADDR: {ret.Error}");
@@ -375,7 +375,7 @@ class Camera
}
{
var ret = await UDPClientPool.WriteAddr(this.ep, this.taskID, CameraAddr.STORE_NUM, frameLength);
var ret = await UDPClientPool.WriteAddr(this.ep, this.taskID, CameraAddr.DMA0_END_WRITE_ADDR, FrameAddr + frameLength - 1);
if (!ret.IsSuccessful)
{
logger.Error($"Failed to write STORE_NUM: {ret.Error}");
@@ -635,7 +635,7 @@ class Camera
{
var basicRegisters = new UInt16[][]
{
[0x3103, 0x03], // system clock from pad, bit[1]
[0x3103, 0x03], // system clock from pad, bit[1] //02
[0x3017, 0xff],
[0x3018, 0xff],
[0x3037, 0x13],
@@ -750,6 +750,7 @@ class Camera
[0x3c04, 0x28],
[0x3c05, 0x98],
[0x3c06, 0x00],
[0x3c07, 0x07],
[0x3c08, 0x00],
[0x3c09, 0x1c],
[0x3c0a, 0x9c],
@@ -803,12 +804,12 @@ class Camera
{
var aecRegisters = new UInt16[][]
{
[0x3a0f, 0x30], // AEC控制;stable range in high
[0x3a10, 0x28], // AEC控制;stable range in low
[0x3a1b, 0x30], // AEC控制;stable range out high
[0x3a1e, 0x26], // AEC控制;stable range out low
[0x3a11, 0x60], // AEC控制; fast zone high
[0x3a1f, 0x14], // AEC控制; fast zone low
[0x3a0f, 0x30], // AEC控制;stable range in high //78
[0x3a10, 0x28], // AEC控制;stable range in low //68
[0x3a1b, 0x30], // AEC控制;stable range out high //78
[0x3a1e, 0x26], // AEC控制;stable range out low //68
[0x3a11, 0x60], // AEC控制; fast zone high //D0
[0x3a1f, 0x14], // AEC控制; fast zone low //40
[0x3b07, 0x0a] // 帧曝光模式
};
@@ -952,7 +953,7 @@ class Camera
{
var timingRegisters = new UInt16[][]
{
[0x3035, 0x41], // 60fps
[0x3035, 0x21], // 60fps
[0x3036, PLL_MUX],// PLL倍频
[0x3c07, 0x08],
[0x3820, 0x41], // vflip