Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
Repozitorijs ir arhivēts. Tam var aplūkot failus un to var klonēt, bet nevar iesūtīt jaunas izmaiņas, kā arī atvērt jaunas problēmas/izmaiņu pieprasījumus.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. """
  2. mbed SDK
  3. Copyright (c) 2011-2013 ARM Limited
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. """
  14. from host_test import Test
  15. from mbedrpc import SerialRPC, DigitalOut, DigitalIn, pin
  16. class RpcTest(Test):
  17. def test(self):
  18. self.notify("RPC Test")
  19. s = SerialRPC(self.mbed.port, debug=True)
  20. self.notify("Init remote objects")
  21. p_out = pin("p10")
  22. p_in = pin("p11")
  23. if hasattr(self.mbed.options, 'micro'):
  24. if self.mbed.options.micro == 'M0+':
  25. print "Freedom Board: PTA12 <-> PTC4"
  26. p_out = pin("PTA12")
  27. p_in = pin("PTC4")
  28. self.output = DigitalOut(s, p_out);
  29. self.input = DigitalIn(s, p_in);
  30. self.check = True
  31. self.write_read_test(1)
  32. self.write_read_test(0)
  33. return self.check
  34. def write_read_test(self, v):
  35. self.notify("Check %d" % v)
  36. self.output.write(v)
  37. if self.input.read() != v:
  38. self.notify("ERROR")
  39. self.check = False
  40. else:
  41. self.notify("OK")
  42. if __name__ == '__main__':
  43. RpcTest().run()