Serial port program to write file/read to file from tty?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












2















i'm looking for some commandline program which I can use to send and receive data to/from serial port. I would like to automate my testing process - start test script which will send file to ttyPC, receive output to file and then compare results.
First I tried with cat with two processes :



# output
echo "Output"
cat /dev/ttyPC > ./out/out$fileNumber.txt &
outputPID=$!

#input
echo "Input"
cat ./in/in$fileNumber.txt > /dev/ttyPC


But this is not stable. Sometimes it's sending data constantly or have problem "file previously opened" or second tty opening closes first cat.



Then I tried with minicom (script.txt is sending data) minicom -D /dev/ttyPC -b 115200 -8 -C log1.txt -S script.txt but i cannot set parity from commandline.



Is there something better?










share|improve this question
























  • You could use cu

    – wurtel
    Feb 13 at 10:57















2















i'm looking for some commandline program which I can use to send and receive data to/from serial port. I would like to automate my testing process - start test script which will send file to ttyPC, receive output to file and then compare results.
First I tried with cat with two processes :



# output
echo "Output"
cat /dev/ttyPC > ./out/out$fileNumber.txt &
outputPID=$!

#input
echo "Input"
cat ./in/in$fileNumber.txt > /dev/ttyPC


But this is not stable. Sometimes it's sending data constantly or have problem "file previously opened" or second tty opening closes first cat.



Then I tried with minicom (script.txt is sending data) minicom -D /dev/ttyPC -b 115200 -8 -C log1.txt -S script.txt but i cannot set parity from commandline.



Is there something better?










share|improve this question
























  • You could use cu

    – wurtel
    Feb 13 at 10:57













2












2








2








i'm looking for some commandline program which I can use to send and receive data to/from serial port. I would like to automate my testing process - start test script which will send file to ttyPC, receive output to file and then compare results.
First I tried with cat with two processes :



# output
echo "Output"
cat /dev/ttyPC > ./out/out$fileNumber.txt &
outputPID=$!

#input
echo "Input"
cat ./in/in$fileNumber.txt > /dev/ttyPC


But this is not stable. Sometimes it's sending data constantly or have problem "file previously opened" or second tty opening closes first cat.



Then I tried with minicom (script.txt is sending data) minicom -D /dev/ttyPC -b 115200 -8 -C log1.txt -S script.txt but i cannot set parity from commandline.



Is there something better?










share|improve this question
















i'm looking for some commandline program which I can use to send and receive data to/from serial port. I would like to automate my testing process - start test script which will send file to ttyPC, receive output to file and then compare results.
First I tried with cat with two processes :



# output
echo "Output"
cat /dev/ttyPC > ./out/out$fileNumber.txt &
outputPID=$!

#input
echo "Input"
cat ./in/in$fileNumber.txt > /dev/ttyPC


But this is not stable. Sometimes it's sending data constantly or have problem "file previously opened" or second tty opening closes first cat.



Then I tried with minicom (script.txt is sending data) minicom -D /dev/ttyPC -b 115200 -8 -C log1.txt -S script.txt but i cannot set parity from commandline.



Is there something better?







tty serial-port minicom






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 13 at 8:28







s.paszko

















asked Feb 13 at 8:22









s.paszkos.paszko

10010




10010












  • You could use cu

    – wurtel
    Feb 13 at 10:57

















  • You could use cu

    – wurtel
    Feb 13 at 10:57
















You could use cu

– wurtel
Feb 13 at 10:57





You could use cu

– wurtel
Feb 13 at 10:57










2 Answers
2






active

oldest

votes


















1














minicom takes its settings primarily from a configuration file. The defaults are in /etc/minicom/minirc.dfl, but you can have other configurations saved as /etc/minicom/minirc.<configuration name>, or in your home directory as ~/.minirc.<configuration name>.



You can set up one or more prepared configuration files with /dev/ttyPC as the default port and with the speed and parity settings according to your needs. For example, run minicom -s ttyPC as root, go to Serial port setup menu, adjust things (including parity) to suit your needs, then select Save setup as ttyPC and then exit Minicom. Now you should have a /etc/minicom/minirc.ttyPC file. You can use its settings, even as a non-root user, by starting Minicom like minicom ttyPC. If you need multiple sets of configuration settings, repeat as necessary using a different configuration name.



Any command-line options can be used to override settings in the configuration file. So you could simply have multiple configuration files with all the possible parity settings, and override the rest using command line options.



The minicom configuration file is just text: if you need to fully automate the set-up of your test environment, your script could include the contents of the configuration file and write the configuration file before starting to use minicom.






share|improve this answer























  • I tried your solution. Created configuration file and then run command minicom -D /dev/ttyPC -C log1.txt < in/in1.txt. Looks OK, but minicom closes when STDIN stream ends. It's a problem for me because i want to wait on complet transfer from ttyPC.

    – s.paszko
    Feb 13 at 9:39


















0














I've written python script to solve my problem. This script takes serial port device, input file and output file as an arguments and then sent input file content to serial port and reads simultanously (Amount of bytes equal to input file size) to output file. If everything is readen or 5s of no data happend then script closes port and exits.



https://github.com/folkien/pyIoCat



usage: serialCat [-h] -i INPUTFILE -o OUTPUTFILE -d DEVICE [-B BAUDRATE]
[-P PARITY]

optional arguments:
-h, --help show this help message and exit
-i INPUTFILE, --inputFile INPUTFILE
input file
-o OUTPUTFILE, --outputFile OUTPUTFILE
output file
-d DEVICE, --device DEVICE
tty Device
-B BAUDRATE, --baudrate BAUDRATE
-P PARITY, --parity PARITY





share|improve this answer






















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f500342%2fserial-port-program-to-write-file-read-to-file-from-tty%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    minicom takes its settings primarily from a configuration file. The defaults are in /etc/minicom/minirc.dfl, but you can have other configurations saved as /etc/minicom/minirc.<configuration name>, or in your home directory as ~/.minirc.<configuration name>.



    You can set up one or more prepared configuration files with /dev/ttyPC as the default port and with the speed and parity settings according to your needs. For example, run minicom -s ttyPC as root, go to Serial port setup menu, adjust things (including parity) to suit your needs, then select Save setup as ttyPC and then exit Minicom. Now you should have a /etc/minicom/minirc.ttyPC file. You can use its settings, even as a non-root user, by starting Minicom like minicom ttyPC. If you need multiple sets of configuration settings, repeat as necessary using a different configuration name.



    Any command-line options can be used to override settings in the configuration file. So you could simply have multiple configuration files with all the possible parity settings, and override the rest using command line options.



    The minicom configuration file is just text: if you need to fully automate the set-up of your test environment, your script could include the contents of the configuration file and write the configuration file before starting to use minicom.






    share|improve this answer























    • I tried your solution. Created configuration file and then run command minicom -D /dev/ttyPC -C log1.txt < in/in1.txt. Looks OK, but minicom closes when STDIN stream ends. It's a problem for me because i want to wait on complet transfer from ttyPC.

      – s.paszko
      Feb 13 at 9:39















    1














    minicom takes its settings primarily from a configuration file. The defaults are in /etc/minicom/minirc.dfl, but you can have other configurations saved as /etc/minicom/minirc.<configuration name>, or in your home directory as ~/.minirc.<configuration name>.



    You can set up one or more prepared configuration files with /dev/ttyPC as the default port and with the speed and parity settings according to your needs. For example, run minicom -s ttyPC as root, go to Serial port setup menu, adjust things (including parity) to suit your needs, then select Save setup as ttyPC and then exit Minicom. Now you should have a /etc/minicom/minirc.ttyPC file. You can use its settings, even as a non-root user, by starting Minicom like minicom ttyPC. If you need multiple sets of configuration settings, repeat as necessary using a different configuration name.



    Any command-line options can be used to override settings in the configuration file. So you could simply have multiple configuration files with all the possible parity settings, and override the rest using command line options.



    The minicom configuration file is just text: if you need to fully automate the set-up of your test environment, your script could include the contents of the configuration file and write the configuration file before starting to use minicom.






    share|improve this answer























    • I tried your solution. Created configuration file and then run command minicom -D /dev/ttyPC -C log1.txt < in/in1.txt. Looks OK, but minicom closes when STDIN stream ends. It's a problem for me because i want to wait on complet transfer from ttyPC.

      – s.paszko
      Feb 13 at 9:39













    1












    1








    1







    minicom takes its settings primarily from a configuration file. The defaults are in /etc/minicom/minirc.dfl, but you can have other configurations saved as /etc/minicom/minirc.<configuration name>, or in your home directory as ~/.minirc.<configuration name>.



    You can set up one or more prepared configuration files with /dev/ttyPC as the default port and with the speed and parity settings according to your needs. For example, run minicom -s ttyPC as root, go to Serial port setup menu, adjust things (including parity) to suit your needs, then select Save setup as ttyPC and then exit Minicom. Now you should have a /etc/minicom/minirc.ttyPC file. You can use its settings, even as a non-root user, by starting Minicom like minicom ttyPC. If you need multiple sets of configuration settings, repeat as necessary using a different configuration name.



    Any command-line options can be used to override settings in the configuration file. So you could simply have multiple configuration files with all the possible parity settings, and override the rest using command line options.



    The minicom configuration file is just text: if you need to fully automate the set-up of your test environment, your script could include the contents of the configuration file and write the configuration file before starting to use minicom.






    share|improve this answer













    minicom takes its settings primarily from a configuration file. The defaults are in /etc/minicom/minirc.dfl, but you can have other configurations saved as /etc/minicom/minirc.<configuration name>, or in your home directory as ~/.minirc.<configuration name>.



    You can set up one or more prepared configuration files with /dev/ttyPC as the default port and with the speed and parity settings according to your needs. For example, run minicom -s ttyPC as root, go to Serial port setup menu, adjust things (including parity) to suit your needs, then select Save setup as ttyPC and then exit Minicom. Now you should have a /etc/minicom/minirc.ttyPC file. You can use its settings, even as a non-root user, by starting Minicom like minicom ttyPC. If you need multiple sets of configuration settings, repeat as necessary using a different configuration name.



    Any command-line options can be used to override settings in the configuration file. So you could simply have multiple configuration files with all the possible parity settings, and override the rest using command line options.



    The minicom configuration file is just text: if you need to fully automate the set-up of your test environment, your script could include the contents of the configuration file and write the configuration file before starting to use minicom.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Feb 13 at 9:12









    telcoMtelcoM

    18.8k12347




    18.8k12347












    • I tried your solution. Created configuration file and then run command minicom -D /dev/ttyPC -C log1.txt < in/in1.txt. Looks OK, but minicom closes when STDIN stream ends. It's a problem for me because i want to wait on complet transfer from ttyPC.

      – s.paszko
      Feb 13 at 9:39

















    • I tried your solution. Created configuration file and then run command minicom -D /dev/ttyPC -C log1.txt < in/in1.txt. Looks OK, but minicom closes when STDIN stream ends. It's a problem for me because i want to wait on complet transfer from ttyPC.

      – s.paszko
      Feb 13 at 9:39
















    I tried your solution. Created configuration file and then run command minicom -D /dev/ttyPC -C log1.txt < in/in1.txt. Looks OK, but minicom closes when STDIN stream ends. It's a problem for me because i want to wait on complet transfer from ttyPC.

    – s.paszko
    Feb 13 at 9:39





    I tried your solution. Created configuration file and then run command minicom -D /dev/ttyPC -C log1.txt < in/in1.txt. Looks OK, but minicom closes when STDIN stream ends. It's a problem for me because i want to wait on complet transfer from ttyPC.

    – s.paszko
    Feb 13 at 9:39













    0














    I've written python script to solve my problem. This script takes serial port device, input file and output file as an arguments and then sent input file content to serial port and reads simultanously (Amount of bytes equal to input file size) to output file. If everything is readen or 5s of no data happend then script closes port and exits.



    https://github.com/folkien/pyIoCat



    usage: serialCat [-h] -i INPUTFILE -o OUTPUTFILE -d DEVICE [-B BAUDRATE]
    [-P PARITY]

    optional arguments:
    -h, --help show this help message and exit
    -i INPUTFILE, --inputFile INPUTFILE
    input file
    -o OUTPUTFILE, --outputFile OUTPUTFILE
    output file
    -d DEVICE, --device DEVICE
    tty Device
    -B BAUDRATE, --baudrate BAUDRATE
    -P PARITY, --parity PARITY





    share|improve this answer



























      0














      I've written python script to solve my problem. This script takes serial port device, input file and output file as an arguments and then sent input file content to serial port and reads simultanously (Amount of bytes equal to input file size) to output file. If everything is readen or 5s of no data happend then script closes port and exits.



      https://github.com/folkien/pyIoCat



      usage: serialCat [-h] -i INPUTFILE -o OUTPUTFILE -d DEVICE [-B BAUDRATE]
      [-P PARITY]

      optional arguments:
      -h, --help show this help message and exit
      -i INPUTFILE, --inputFile INPUTFILE
      input file
      -o OUTPUTFILE, --outputFile OUTPUTFILE
      output file
      -d DEVICE, --device DEVICE
      tty Device
      -B BAUDRATE, --baudrate BAUDRATE
      -P PARITY, --parity PARITY





      share|improve this answer

























        0












        0








        0







        I've written python script to solve my problem. This script takes serial port device, input file and output file as an arguments and then sent input file content to serial port and reads simultanously (Amount of bytes equal to input file size) to output file. If everything is readen or 5s of no data happend then script closes port and exits.



        https://github.com/folkien/pyIoCat



        usage: serialCat [-h] -i INPUTFILE -o OUTPUTFILE -d DEVICE [-B BAUDRATE]
        [-P PARITY]

        optional arguments:
        -h, --help show this help message and exit
        -i INPUTFILE, --inputFile INPUTFILE
        input file
        -o OUTPUTFILE, --outputFile OUTPUTFILE
        output file
        -d DEVICE, --device DEVICE
        tty Device
        -B BAUDRATE, --baudrate BAUDRATE
        -P PARITY, --parity PARITY





        share|improve this answer













        I've written python script to solve my problem. This script takes serial port device, input file and output file as an arguments and then sent input file content to serial port and reads simultanously (Amount of bytes equal to input file size) to output file. If everything is readen or 5s of no data happend then script closes port and exits.



        https://github.com/folkien/pyIoCat



        usage: serialCat [-h] -i INPUTFILE -o OUTPUTFILE -d DEVICE [-B BAUDRATE]
        [-P PARITY]

        optional arguments:
        -h, --help show this help message and exit
        -i INPUTFILE, --inputFile INPUTFILE
        input file
        -o OUTPUTFILE, --outputFile OUTPUTFILE
        output file
        -d DEVICE, --device DEVICE
        tty Device
        -B BAUDRATE, --baudrate BAUDRATE
        -P PARITY, --parity PARITY






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 13 at 13:55









        s.paszkos.paszko

        10010




        10010



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f500342%2fserial-port-program-to-write-file-read-to-file-from-tty%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown






            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?