send hex as characters to output to remote end












0















I'm doing a project for a microcontroller that involves sending and receiving special (non-printable character) data through its serial port.



I found myself a simulator (ucsim) so I can test things out. I want to take advantage of its bi-directional serial port.



I tried its option of using unix files for port operation, and that worked a little clunky (probably because it relies on the operation of the termios subsystem).



So I have better ideas. I can use the program to make a server via TCP/IP that acts like a microcontroller serial port. The closest "perfect" setup I have is running "realterm" in Wine. It's a terminal designed for engineers. The problem with that program is that it locks up at unexpected times.



So I made myself an excellent setup to log the data coming from the virtual microcontroller (ucsim) as follows:



1. Execute: s51 -k9876 /path/to/hexfile.hex
2. Open a second window
3. Run in 2nd window: nc 127.0.0.1 9876 | od -tx1 -w30
4. type r in simulator window to run 8051 machine code
5. Switch to 2nd window to see results


s51 is the main executable unpacked from ucsim that simulates an 8051 processor and the hexfile is my code that is injected into it. The number after -k is the port number I chose to use as the server port. This setup works without lockup.



Now what I want to do is also the reverse of what I demonstrated.



I want to be able to specify the data I want to send back to the live simulator server (at address 127.0.0.1 port 9876) in hexadecimal format, but the server will receive it as raw character data.



For example, Say I want the server to receive "ABCD" without quotes. Then I want to specify that I want to send 41h 42h 43h and 44h respectively since those are hexadecimal values for each of the characters.



So far, I can achieve the first step with the following command:



echo -e -n "x41x42x43x44"


Now if the server was instead a simple file, I could do the following:



echo -e -n "x41x42x43x44" > /path/to/file


But I want to send it to the server so it can process the data.



How do I go about doing this?










share|improve this question



























    0















    I'm doing a project for a microcontroller that involves sending and receiving special (non-printable character) data through its serial port.



    I found myself a simulator (ucsim) so I can test things out. I want to take advantage of its bi-directional serial port.



    I tried its option of using unix files for port operation, and that worked a little clunky (probably because it relies on the operation of the termios subsystem).



    So I have better ideas. I can use the program to make a server via TCP/IP that acts like a microcontroller serial port. The closest "perfect" setup I have is running "realterm" in Wine. It's a terminal designed for engineers. The problem with that program is that it locks up at unexpected times.



    So I made myself an excellent setup to log the data coming from the virtual microcontroller (ucsim) as follows:



    1. Execute: s51 -k9876 /path/to/hexfile.hex
    2. Open a second window
    3. Run in 2nd window: nc 127.0.0.1 9876 | od -tx1 -w30
    4. type r in simulator window to run 8051 machine code
    5. Switch to 2nd window to see results


    s51 is the main executable unpacked from ucsim that simulates an 8051 processor and the hexfile is my code that is injected into it. The number after -k is the port number I chose to use as the server port. This setup works without lockup.



    Now what I want to do is also the reverse of what I demonstrated.



    I want to be able to specify the data I want to send back to the live simulator server (at address 127.0.0.1 port 9876) in hexadecimal format, but the server will receive it as raw character data.



    For example, Say I want the server to receive "ABCD" without quotes. Then I want to specify that I want to send 41h 42h 43h and 44h respectively since those are hexadecimal values for each of the characters.



    So far, I can achieve the first step with the following command:



    echo -e -n "x41x42x43x44"


    Now if the server was instead a simple file, I could do the following:



    echo -e -n "x41x42x43x44" > /path/to/file


    But I want to send it to the server so it can process the data.



    How do I go about doing this?










    share|improve this question

























      0












      0








      0








      I'm doing a project for a microcontroller that involves sending and receiving special (non-printable character) data through its serial port.



      I found myself a simulator (ucsim) so I can test things out. I want to take advantage of its bi-directional serial port.



      I tried its option of using unix files for port operation, and that worked a little clunky (probably because it relies on the operation of the termios subsystem).



      So I have better ideas. I can use the program to make a server via TCP/IP that acts like a microcontroller serial port. The closest "perfect" setup I have is running "realterm" in Wine. It's a terminal designed for engineers. The problem with that program is that it locks up at unexpected times.



      So I made myself an excellent setup to log the data coming from the virtual microcontroller (ucsim) as follows:



      1. Execute: s51 -k9876 /path/to/hexfile.hex
      2. Open a second window
      3. Run in 2nd window: nc 127.0.0.1 9876 | od -tx1 -w30
      4. type r in simulator window to run 8051 machine code
      5. Switch to 2nd window to see results


      s51 is the main executable unpacked from ucsim that simulates an 8051 processor and the hexfile is my code that is injected into it. The number after -k is the port number I chose to use as the server port. This setup works without lockup.



      Now what I want to do is also the reverse of what I demonstrated.



      I want to be able to specify the data I want to send back to the live simulator server (at address 127.0.0.1 port 9876) in hexadecimal format, but the server will receive it as raw character data.



      For example, Say I want the server to receive "ABCD" without quotes. Then I want to specify that I want to send 41h 42h 43h and 44h respectively since those are hexadecimal values for each of the characters.



      So far, I can achieve the first step with the following command:



      echo -e -n "x41x42x43x44"


      Now if the server was instead a simple file, I could do the following:



      echo -e -n "x41x42x43x44" > /path/to/file


      But I want to send it to the server so it can process the data.



      How do I go about doing this?










      share|improve this question














      I'm doing a project for a microcontroller that involves sending and receiving special (non-printable character) data through its serial port.



      I found myself a simulator (ucsim) so I can test things out. I want to take advantage of its bi-directional serial port.



      I tried its option of using unix files for port operation, and that worked a little clunky (probably because it relies on the operation of the termios subsystem).



      So I have better ideas. I can use the program to make a server via TCP/IP that acts like a microcontroller serial port. The closest "perfect" setup I have is running "realterm" in Wine. It's a terminal designed for engineers. The problem with that program is that it locks up at unexpected times.



      So I made myself an excellent setup to log the data coming from the virtual microcontroller (ucsim) as follows:



      1. Execute: s51 -k9876 /path/to/hexfile.hex
      2. Open a second window
      3. Run in 2nd window: nc 127.0.0.1 9876 | od -tx1 -w30
      4. type r in simulator window to run 8051 machine code
      5. Switch to 2nd window to see results


      s51 is the main executable unpacked from ucsim that simulates an 8051 processor and the hexfile is my code that is injected into it. The number after -k is the port number I chose to use as the server port. This setup works without lockup.



      Now what I want to do is also the reverse of what I demonstrated.



      I want to be able to specify the data I want to send back to the live simulator server (at address 127.0.0.1 port 9876) in hexadecimal format, but the server will receive it as raw character data.



      For example, Say I want the server to receive "ABCD" without quotes. Then I want to specify that I want to send 41h 42h 43h and 44h respectively since those are hexadecimal values for each of the characters.



      So far, I can achieve the first step with the following command:



      echo -e -n "x41x42x43x44"


      Now if the server was instead a simple file, I could do the following:



      echo -e -n "x41x42x43x44" > /path/to/file


      But I want to send it to the server so it can process the data.



      How do I go about doing this?







      networking io-redirection ip serial-port port






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 11 mins ago









      MikeMike

      1163




      1163






















          0






          active

          oldest

          votes











          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%2f505051%2fsend-hex-as-characters-to-output-to-remote-end%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f505051%2fsend-hex-as-characters-to-output-to-remote-end%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

          宮崎県

          濃尾地震

          シテ島