user:kluong:feature_idea_-_staging_environment

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
user:kluong:feature_idea_-_staging_environment [2021/10/22 15:00]
kluong [Gateway - testing changes]
user:kluong:feature_idea_-_staging_environment [2021/10/23 17:42] (current)
kluong
Line 279: Line 279:
  
 ==== Gateway - testing changes ==== ==== Gateway - testing changes ====
- + 
-It's not necessarily practical to have hardware to test with all of the time and often hardware might not be available anyways. Luckily, with software we can work around this.  +
 Options for testing Options for testing
  
Line 289: Line 287:
   * Connect the gateway to a "​fake"​ xbee virtually, using a pty and another script   * Connect the gateway to a "​fake"​ xbee virtually, using a pty and another script
   * Mock out the serial device completely in python   * Mock out the serial device completely in python
 +
 +It's not necessarily practical to have hardware to test with all of the time and often hardware might not be available anyways. Luckily, with software we can work around this. 
 +
 +**Note: development for the gateway should generally be done in a linux-based environment.** The gateway code was primarily designed only for linux-based environments and may not run locally.
 +
 +You can make a "​fake"​ xbee network using the following python script:
 +
 +<​code>​
 +import os
 +import errno
 +import time
 +
 +def symlink_force(target,​ link_name):
 +    try:
 +        os.symlink(target,​ link_name)
 +    except OSError as e:
 +        if e.errno == errno.EEXIST:​
 +            os.remove(link_name)
 +            os.symlink(target,​ link_name)
 +        else:
 +            raise e
 +
 +def valid_packets():​
 +    packets = {}
 +    packets['​heartbeat'​] = "​\x7e\x00\x16\x90\x00\x7d\x33\xa2\x00\x40\xe6\x4b\x5e\x03\xfd\x01\x00\x00\xff\xff\xf0\xfa\x23\x00\x2b\x02\xb2"​
 +    packets['​apple'​] = "​\x7e\x00\x22\x90\x00\x7d\x33\xa2\x00\x40\x9f\x27\xa7\x29\x6c\x01\x01\x00\xff\xff\x80\x6f\x69\x3d\x06\x0f\x71\x7d\x33\x5a\x8a\x01\x00\x76\x01\x22\x00\x6e\x09\x55"​
 +    packets['​cranberry'​] = "​\x7e\x00\x22\x90\x00\x7d\x33\xa2\x00\x41\x25\xe5\x88\x0c\x83\x01\x02\x00\xff\xff\x7c\xf3\x05\x00\xba\x0f\x5c\x08\x05\x00\x20\x73\x3b\x00\xdd\x8b\x01\x00\x7a"​
 +    packets['​dragonfruit'​] = "​\x7e\x00\x24\x90\x00\x7d\x33\xa2\x00\x40\xe6\x72\x7d\x5e\x30\x18\x01\x03\x00\xff\xff\x30\xc8\x07\x00\x6b\x0d\xf4\x00\x06\x00\x00\x00\xb6\x72\x37\x00\xfe\x8b\x01\x00\x00"​
 +    packets['​snapdragon'​] = "​\x7e\x00\x22\x90\x00\x7d\x33\xa2\x00\x40\xa3\x53\x7d\x5e\x20\x9c\x01\x04\x00\xff\xff\x12\xe4\x49\x00\xca\x0d\x44\x0c\x2c\x31\x01\x00\x2f\x01\x34\x00\x64\x00\xbb"​
 +
 +    return packets
 +
 +master_fd, slave_fd = os.openpty()
 +symlink_force(os.ttyname(slave_fd),​ '/​tmp/​fakexbee'​)
 +
 +
 +packets = valid_packets()
 +while True:
 +    for key in packets:
 +        os.write(master_fd,​ bytes(packets[key]))
 +        time.sleep(1)
 +
 +</​code>​
  
  
  • user/kluong/feature_idea_-_staging_environment.1634914852.txt.gz
  • Last modified: 2021/10/22 15:00
  • by kluong