我正在尝试将数据从arduino发送到RPi而不是数据库。但是当我运行我的Python代码时:
import serial
import time
import MySQLdb as mdb
arduino = serial.Serial("/dev/ttyACM0")
arduino.baudrate=9600
data=arduino.readLine()
time.sleep()
data = arduino.readLine()
blah blah blah...
IT给我一个错误
AttributeError:' Serial'对象没有属性' readLine'
我该如何解决这个问题?
答案 0 :(得分:0)
Serial没有实现readLine
。请尝试使用read
。您可能首先需要open
它。
答案 1 :(得分:0)
正确的功能是:
angular.module('ui.bootstrap.demo').controller('TypeaheadCtrl',function($scope, $http) {
$scope.getLocation = function(val) {
return $http.get('//maps.googleapis.com/maps/api/geocode/json', {
params: {
address: val,
sensor: false
}
}).then(function(response){
return response.data.results.map(function(item){
return item.formatted_address;
});
});
};
<h4>Asynchronous results</h4>
<pre>Model: {{asyncSelected | json}}</pre>
<input type="text" ng-model="asyncSelected" placeholder="Locations loaded via $http" uib-typeahead="address for address in getLocation($viewValue)" typeahead-loading="loadingLocations" typeahead-no-results="noResults" class="form-control">
<i ng-show="loadingLocations" class="glyphicon glyphicon-refresh"></i>
<div ng-show="noResults">
<i class="glyphicon glyphicon-remove"></i> No Results Found
</div>
(&#34中只有小写字母; readline&#34;)
读数的迭代最好放在循环中,例如:
arduino.readline()