feat: 添加I2C与Camera初始化的支持
This commit is contained in:
@@ -35,6 +35,25 @@ class Camera
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public async ValueTask<Result<bool>> Init()
|
||||
{
|
||||
var i2c = new Peripherals.I2cClient.I2c(this.address, this.port, this.timeout);
|
||||
var ret = await i2c.WriteData(0x78, new byte[] { 0x08, 0x30, 0x02 }, Peripherals.I2cClient.I2cProtocol.I2c);
|
||||
if (!ret.IsSuccessful)
|
||||
{
|
||||
logger.Error($"I2C write failed during camera initialization for {this.address}:{this.port}, error: {ret.Error}");
|
||||
return new(ret.Error);
|
||||
}
|
||||
|
||||
if (!ret.Value)
|
||||
{
|
||||
logger.Error($"I2C write returned unsuccessful result during camera initialization for {this.address}:{this.port}");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取一帧图像数据
|
||||
/// </summary>
|
||||
@@ -47,7 +66,7 @@ class Camera
|
||||
logger.Trace($"Clear up udp server {this.address} receive data");
|
||||
|
||||
// 使用UDPClientPool读取图像帧数据
|
||||
var result = await UDPClientPool.ReadAddrBytes(
|
||||
var result = await UDPClientPool.ReadAddr4Bytes(
|
||||
this.ep,
|
||||
2, // taskID
|
||||
CameraAddr.Base,
|
||||
|
||||
Reference in New Issue
Block a user