SystecCAN 플러그인 사용
SystecCAN 플러그인은 SYS TEC CAN 어댑터와 함께 작동하도록 로우레벨 API를 캡슐화합니다.
이 플러그인에는 SYS TEC CAN 장치 드라이버와 usbcan32.dll(64비트 빌드의 경우 usbcan64.dll)이 필요합니다.
CAN 버스 디바이스 생성
먼저 QCanBus 에서 원하는 플러그인을 제공하는지 확인해야 합니다:
if (QCanBus::instance()->plugins().contains(QStringLiteral("systeccan"))) { // plugin available }
여기서 systeccan은 플러그인 이름입니다.
다음으로 특정 인터페이스에 대한 연결을 설정할 수 있습니다:
QString 오류 문자열;QCanBusDevice *device = QCanBus::instance()->createDevice( QStringLiteral("systeccan"), QStringLiteral("can0.0"), &errorString);if (!device) { // 오류 처리는 여기서 진행됩니다. qDebug << errorString; } else { device->connectDevice(); }
여기서, can0.0은 활성 CAN 인터페이스 이름(인터페이스 0, 채널 0)입니다. SystecCAN 플러그인은 can0.0부터 can63.1까지 64개의 USB 인터페이스(소위 모듈)를 지원합니다. 각 모듈은 하나 또는 두 개의 채널을 가질 수 있으며, canX.0 또는 canX.1 인덱스로 액세스할 수 있습니다. availableDevices () 메서드는 현재 사용 가능한 장치 목록을 반환합니다.
참고: SYS TEC은 8채널 또는 16채널 CAN 인터페이스도 제공합니다. 이러한 장치는 내부적으로 USB 허브와 여러 개의 2채널 모듈로 구성됩니다.
이제 장치가 CAN 프레임 쓰기 및 읽기를 위해 열려 있습니다:
QCanBusFrame frame; frame.setFrameId(8); QByteArray payload("A36E"); frame.setPayload(payload); device->writeFrame(frame);
읽기는 readFrame() 메서드를 사용하여 수행할 수 있습니다. framesReceived () 신호는 읽기에 사용할 수 있는 새 프레임이 하나 이상 있으면 전송됩니다:
QCanBusFrame frame = device->readFrame();
SystecCAN은 setConfigurationParameter()를 통해 제어할 수 있는 다음 구성을 지원합니다:
구성 매개변수 키 | 설명 |
---|---|
QCanBusDevice::BitRateKey | CAN 버스 연결의 비트 전송률을 결정합니다. 지원되는 비트 전송률은 다음과 같습니다: 10000, 20000, 50000, 100000, 125000, 250000, 500000, 800000, 1000000. 이 구성 매개변수는 QCanBusDevice 에 연결되지 않은 상태에서만 조정할 수 있습니다. |
QCanBusDevice::ReceiveOwnKey | CAN 프레임을 보낸 채널과 동일한 채널에서 CAN 프레임을 수신하는 것은 기본적으로 비활성화되어 있습니다. 이 옵션을 활성화하면 수신된 프레임에 QCanBusFrame::hasLocalEcho()가 표시됩니다. |
SystecCAN은 다음과 같은 추가 기능을 지원합니다:
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.