Skip to content
  • 1 Votes
    6 Posts
    886 Views
    jsulmJ

    @vishbynature said in Qt Program start on bootup and start GUI interaction automatically:

    As soon as MainWindow GUI appears I should start SPI data transfer.

    Sure. You can use QTimer to trigger the transfer.

  • 0 Votes
    4 Posts
    885 Views
    K

    If your Raspi have a 'generic' SPI driver (aka spidev), than I don't see any problems. Just google about 'spidev' (how to configure, how to open/close, how to read/write).

  • 0 Votes
    14 Posts
    6k Views
    A
    Root permission to the program
    2.Spi Begin function

    After these modifications it started working. beginners mistake.

  • QtSerialPort with /dev/spidev

    Unsolved QtonPi
    5
    0 Votes
    5 Posts
    5k Views
    P

    Getting back to document conclusions of my research on best practice of using RaspiComm RS-485 under Qt for anybody, who finds this thread useful (I expect many of it is valid for RS-232 on same board as well, did not test myself):

    Do not try to implement communication with MAX3140 UART chip yourself (maybe except of asm based implementation, what is however most probably unnecessary exertion). I succeeded to implement it based on kernel /dev/spidev0.0 only to find out that even this partially system driver supported solution is too slow for even 19 200 Bd speed (loosing about 5 characters on one received).
    I myself feared about RaspiComm RS-485 driver /dev/ttyRPC0 based on some forums complaints and not clear versioning, however found out, that the forum thread was heavy outdated. These official installation instructions worked like a charm and the resulting driver worked out-of-box for my latest Raspbian Wheezy (4.1.7+ #817). So I strongly recommend to take this approach.

    QSerialPort class has constructor with signature QSerialPort(const QString &, QObject *), where QString may contain even device which is not included in the QList that QSerialPortInfo::availablePorts() returns. This works with no surprise. If one does not set anything than (eventually) baud speed, one gets standard 8 bit, 1 stop bit, no parity without any character translations, good old plain raw binary. So QSerialPort may be used with /dev/ttyRPC0 directly and easily.

    QSerialPort rpc0("/dev/ttyRPC0");
    rpc0.write("Binary request\0even\xffcontaining weird\x03characters", length_of_binary);
    if(rpc0.waitForReadyRead(100)) // Enough long time in miliseconds
    QByteArray data = rpc0.readAll(); // You may have to wait/read repetitively in loop
    // and merge data on higher link speeds

    Hardware of RaspiComm uses RTS pin to select in/out direction of data. CTS is kept active permanently by wiring, so using default use RTS/CTS mode works properly with no inappropriate blocking.

    That's all you should need, so enjoy your communication.

  • 0 Votes
    11 Posts
    4k Views
    jsulmJ

    @Dan90 You are assigning a value to a pointer, but data is actually an array of "unsigned char":

    unsigned char *data = 0b10000000;

    Instead you should do (C++11):

    unsigned char data[] = { (unsigned char)0b10000000 };
  • 0 Votes
    1 Posts
    684 Views
    No one has replied