0

Is it possible to "send" a serial command to the device itself to see the response? I have written a little routine based on a couple of serial sends and receives and want to see if that works out like I want.

EDIT:

I have a device (an AVR with arduino boot loader) and as part of my program, the device exchanges phrases with peripheral devices over a serial connection. Since I have right now just the arduino itself and can't really test, if at least the logic behind the serial part of works out, I would like to get serial commands from somewhere and trigger 'continuous talking', so I want to monitor the response behavior of my module, if it gets a certain command (stability reasons). Instead of waiting for a second device, is it possible to "link the TX/RX line to itself" internally or externally to test my program with itself?

4
  • No idea what you are asking there, sorry. Please flesh out your question with an actual example - your current description is impossible to interpret.
    – Majenko
    Jun 8, 2015 at 14:57
  • Welcome to Arduino SE! I've edited your extra content into the main question. Jun 8, 2015 at 16:23
  • 1
    It sounds like you may be thinking of a serial "loopback" test. On the hardware side, it can be as simple as shunting the transmit pin to the receive pin - just make sure nothing else is hooked up to that transmit pin. Coming up with something useful on the software side may be more interesting; there is also the question of how you are going to monitor it. Jun 8, 2015 at 16:38
  • 1
    But if I recall, there is a resistor between the USB-serial output and the ATmega input on the basic Arduino series, so if you jumper D1 and D0 the ATmega will hear its own transmissions, and a connected PC will passibly see all of it. Just remove the jumper before you try to talk or program with the PC. Jun 8, 2015 at 16:38

1 Answer 1

1

Yes, you can do that by cross-connecting the transmit and receive pins on the Arduino. But then your devices sits there silently murmuring to itself (or not...) and you can't really tell what it's saying, or if it's doing anything unless you can observe some other hardware - LEDs, a 'scope, f/ex.

But why not hand-type or script some messages to it on your PC? If the Arduino sketch would make some brief, coherent replies you could confirm what it's doing and debug it if necessary.

I've done just this in your situation: Two of us defined a serial protocol - the ASCII (for human readability!) commands and replies that either end could make or expect. Then each of us wrote the communication code for one of the two devices and proved that it met the protocol. Once both of us had finished and were confident in our respected communication code, we plugged the two devices together, and - they played! Nicely! :) And if they hadn't we could have eavesdropped on the serial line and printed their attempted conversation to discover where it went wrong.

1
  • That's a good idea!
    – freistil90
    Jun 8, 2015 at 22:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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