📢 Webサイト閉鎖と移転のお知らせ
このWebサイトは2026年9月に閉鎖いたします。
新しい記事は移転先で追加しております。(旧サイトでは記事を追加しておりません)
| 274行目: | 274行目: | ||
// SpiWriter.hファイル | // SpiWriter.hファイル | ||
class SpiWriter : public SpiDevice | |||
{ | |||
Q_OBJECT | |||
public: | |||
using SpiDevice::SpiDevice; | |||
void writeData(const QByteArray& data) | |||
{ | |||
QFuture<void> future = QtConcurrent::run([this, data]() { | |||
QFile spiDevice(m_devicePath); | |||
if (!spiDevice.open(QIODevice::WriteOnly)) { | |||
emit errorOccurred("SPIデバイスのオープンに失敗: " + spiDevice.errorString()); | |||
return; | |||
} | |||
int fd = spiDevice.handle(); | |||
ssize_t ret = write(fd, data.constData(), data.size()); | |||
if (ret < 0) { | |||
emit errorOccurred("SPIの書き込みに失敗"); | |||
} | |||
else { | |||
emit dataWritten(ret); | |||
} | |||
spiDevice.close(); | |||
}); | |||
} | |||
signals: | |||
void dataWritten(int bytes); | |||
}; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
<br> | <br> | ||