port.py
1 # -*- coding: utf-8 -*-
2 
3 import sys
4 from ev3dev import *
5 
6 if __name__ == '__main__':
7  print 'Waiting the EV3 brick online...'
8  if ev3_init() < 1: sys.exit( 1 )
9 
10  print '*** ( EV3 ) Hello! ***'
12 
13  print 'Found ports:'
14  for i in range( PORT_DESC__LIMIT_ ):
15  type_inx = ev3_port_desc_type_inx( i )
16  if type_inx != PORT_TYPE__NONE_:
17  print ' type =', ev3_port_type( type_inx )
18  print ' port =', ev3_port_port_name( i )
19  ok, mode = get_port_mode( i, 256 )
20  if ok:
21  print ' mode =', mode
22 
23  sn = ev3_search_port( INPUT_2, EXT_PORT__NONE_ )
24 
25  print 'Port "%s"' % ( ev3_port_name( INPUT_2, EXT_PORT__NONE_, 0 ))
26  ok, s = get_port_modes( sn, 256 )
27  if ok:
28  print 'Modes:', s
29  else:
30  print 'ERROR: get_port_modes()'
31 
32  ev3_uninit()