0

I wrote a function that sends morse code by manipulating a GPIO pin. The pin is set high for a certain amount of time to signal DOT. Then set low for certain time to signal DOT-DASH space etc.

So the problem is that I send a sequence for example "CBA" and then the program does it and from the cpputest code I can only test the final state of the pins. I would like to write a test to check the time spent in each state and the state of the bit. How is that possible?

augre
  • 330
  • 3
  • 12
  • 1
    You don't set the pin low for DASH, you set the pin high for both DOT and DASH with short and long time-lengths respectively. You set the pin low for the gap between DOTs and DASHes, and longer for the gap between letters. You can most easily check the output with an oscilloscope. On the other hand if you must check the pins programmatically, you can write a Morse code receiver. Although, there is folly in this kind of test if you have made incorrect assumption at both ends. – Weather Vane Sep 20 '16 at 19:06
  • Thank you! I thought maybe instead of do the actual timing I could print the amount of time and state of the pin. I wonder how I could check that from cpputest? – augre Sep 20 '16 at 19:54
  • Well, I recommended a Morse reader. If you had written that *first* you could check your concepts with an actual key, before checking the transmitter output. – Weather Vane Sep 20 '16 at 19:58
  • It seems to me that you want to test if your clock timing is set right, you can't test it from the test framework, since it is 100% hardware. – Felipe Lavratti Oct 28 '16 at 17:03

0 Answers0