This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] 将 M430F 器件连接到 OTG Android 主机时出现问题

Guru**** 662690 points
Other Parts Discussed in Thread: MSP430F5508
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/967727/problem-interfacing-m430f-device-to-an-otg-android-host

主题中讨论的其他器件:MSP430F5508
这个问题让我感到意外! 尽量、我无法用 Android 与包含 MSP430芯片的 USB 转串行转换器进行通信。 我将使用 Xamarin Forms 编写 Android 应用程序、因此 C#是首选语言。 我在 TI 知识库中搜索过、但没有找到与我所需内容接近的示例。 使用驱动器代码中的描述符、我觉得我要将正确的信息传递给它、但我甚至不能肯定数据是否会传递给转换器、更不用说返回了。
我有一个通用开放源码库、允许用户连接到某些标准器件(FTDI、Prolific 等)、但遗憾的是、没有 TI MSP430。 FTDI 代码运行良好。 基本的"驱动程序"代码相当标准、我已经使用.inf 文件中的 VID/PID 创建了自己的 TI_SerialDriver/TI_SerialPort 类。 我的 Android 应用程序实际上可以看到已连接 USB、但我无法从我尝试与之通信的器件获得有效响应。 当然、作为一名软件人员、目前在家中工作、我无法访问范围或监听器。
我已经设置了调试点、可以看到它会找到控制接口以及数据接口以及读取和写入端点。 我在下面添加了一些代码;很高兴发布更多内容、只是这个课程相当大! 提前感谢您的任何帮助。 不知道实际器件型号-芯片上的标签显示:M430F5508  

公共覆盖 int read (byte[] dest、int timeoutMillis)

int numBytesRead = 0;
LOCK (mReadBufferLock)

int readAmt = Math.min (dest.Length、mReadBuffer.Length);
mConnection.BulkTransfer (mReadEndpoint、mReadBuffer、
readAmt、1000);// timeoutMillis);
如果(numBytesRead < 0)

返回0;

Buffer.BlockCopy (mReadBuffer、0、dest、0、numBytesRead);

返回数字字节 Read;

公共覆盖空 SetDTR (bool 值)

mDtr =值;
SetDtrRts();

公共覆盖空 SetRTS (bool 值)

MRTs =值;
SetDtrRts();

公共覆盖空设置参数(int 波特率、int dataBits、stopbits stopbits、奇偶校验)

波特率= 115200;
字节 stopBitsByte = 1;
字节 parityBitesByte = 0;
dataBits = 8;
byte[] msg ={
(字节)(波特率和0xff)、
(字节)(((波特率>> 8)& 0xff)、
(字节)(((波特率>> 16)& 0xff)、
(字节)(((波特率>> 24)& 0xff)、
(字节) dataBits、
stopBitsByte、
parityBitesByte
};

mConnection.ControlTransfer (((UsbAddeding)0x21、0x20、0、0、msg、 MSG.Length,5000);

SetDTR (真);

公共覆盖 int Write (byte[] src、int timeoutMillis)

int offset = 0;

while (offset < src.Length)

int writeLength;
int amtWritten;

锁定(mWriteBufferLock)

byte[] writeBuffer;

writeLength = System.Math.Min (src.Length - offset、mWriteBuffer.Length);
如果(偏移= 0)

writeBuffer = src;

其他

// bulkTransfer 不支持偏移,请制作副本。
Buffer.BlockCopy (src、offset、mWriteBuffer、0、writeLength);
writeBuffer = mWriteBuffer;

amtWritten = mConnection.BulkTransfer (mWriteEndpoint、
writeBuffer、writeLength、timeoutMillis);

if (amtWritten <= 0)

string temp =$"在偏移量{offset}length={src.Length}处写入{writeLength}字节时出错";
_myLogger.Log (temp);
抛出新 IOException (temp);

offset += amtWritten;

返回偏移;

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Wayne、

    您会说您使用 MSP430F5508将 USB 转换为 UART。 现在、F5508没有从 USB 接收任何数据。

    如果是这样、本文档可能会帮助您进行 MSP430芯片的 USB 设计。

    此致、

    现金 Hao

    尽量、我无法用 Android 与包含 MSP430芯片的 USB 转串行转换器进行通信。 我将使用 Xamarin Forms 编写 Android 应用程序、因此 C#是首选语言。 我在 TI 知识库中搜索过、但没有找到与我所需内容接近的示例。 使用驱动器代码中的描述符、我觉得我要将正确的信息传递给它、但我甚至不能肯定数据是否会传递给转换器、更不用说返回了。