2

I have an ancient serial spectrometer which only runs on win9x. I want to convert to a Linux system, but the existing software is proprietary and wont work. I was able to access a console internally on the spectrometer. The console takes keyboard character commands, and sends the output to the serial port.

in vb6 I can write to the com port with char values http://www.gtwiki.org/mwiki/?title=VB_Chr_Values using ComPort.Write(Chr(34))

I am interested in using Qt for the interface, how can I send something to the same effect as ComPort.Write(Chr(34)) using qt?

1
  • Here an example from Qt official site (C++)

    http://qt-project.org/wiki/QtSerialPort

  • If Visual Basic is your background you may prefer Gambas3

    http://gambasdoc.org/help/comp/gb.net/serialport?v3

    Gambas have similar syntax of Visual Basic(VB), and support Qt as GUI tool kit.

    See http://gambasdoc.org/help/comp?v3

  • In Linux/BSD, Serial port is more accessible then windows. So you can even write to it from shell/terminal, or use system call from most programming languages.

    Example in shell with an Android phone as modem, it may help for debugging:

    1. Reading serial port (need to be root):

      sudo su
      cat /dev/ttyACM0
      

      As you can read just few lines as needed:

      head -n2 /dev/ttyACM0
      
    2. Writing serial, Open other terminal tab or window:

      sudo su
      echo -e "AT" > /dev/ttyACM0
      

      It shows OK on reading port window, Also you can sent hexadecimal data (use -n option to avoid sending new line at the end)

      echo -e -n "\x41\x54\x0a" > /dev/ttyACM0
      

      same as:

      echo -e "\x41\x54" > /dev/ttyACM0
      

      Shell will show undisplayed hex as small square with its value written inside it. Try this.

      echo -e "\x13"
      

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.