Skip to content
Parallax Learn (Stage)

Parallax Learn (Stage)

This is the staging site. Please see https://learn.parallax.com for the official site.

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence Tutorial Series
          • Cybersecurity: Radio Data tutorialCybersecurity Tutorial Series
          • cyber:bot Tutorial Series
          • Boe-Bot Tutorial SeriesBoe-Bot Tutorial Series
          • Arduino Shield-Bot Tutorial Series
          • ActivityBot with C TutorialsActivityBot with C Tutorials
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot with BlocklyProp Tutorial Series
          • Scribbler 3 Tutorial SeriesScribbler 3 Tutorial Series
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education Tutorial Series
          • Propeller C-Language BasicsPropeller C Basics and Projects
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit C Tutorial Series
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit BlocklyProp Tutorials
          • Badge WX Tutorial SeriesBadge WX Tutorial Series
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics and Projects
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Cybersecurity: Radio Data

Cybersecurity: Radio Data

Try This: Out of Order

Curious how a dictionary might start out as {‘start’ : 3, ‘after’ : ‘Liftoff!’} in the transmitter but end up as {‘after’ : ‘Liftoff!’, ‘start’ : 3} in the receiver?  You might be able to see it by printing the dictionary immediately after the eval statement.  

  • Modify the countdown_receiver script by adding the statement with the # add comment shown here.  Don’t change anything else in the script.
        dictionary = eval(packet)
        
        print("dictionary: \n", dictionary, "\n")       # add

        value = dictionary['start']
        message = dictionary['after']
  • Flash the receiver with the modified script.
  • Enter 2 at the start prompt and Go!!! at the message prompt.
  • Verity that the sender and receiver terminals resemble these:

What happened?

When you run the modified scripts and enter the start count and message after, it might look like this.  The Send and Receive strings are the same {‘after’: ‘Go!!!’, ‘start’: 2}.  Then, after dictionary = eval(packet), the order of the dictionary has changed to {‘start’: 2, ‘after’: ‘Go!!!’}.  Each value is still paired with its key, but the order of the key-value pairs is different.  

The application still worked correctly because value = dictionary[‘start’] still retrieved the 2 value that was paired with the ‘start’ key.   Likewise, message = dictionary[‘after’] also retrieved the ‘Go!!!’ string value that was paired with the ‘after’ key.   

 


Printer-friendly version
How Radio Data Packets Work
Prev
Your Turn: Add More Data
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn (Stage) • Built with GeneratePress