我想创建一个程序来模拟CAN端口,以便为另一个大型应用程序进行测试.程序应通过此虚拟CAN发送先前记录的数据.有人有这方面的经验吗?
我正在考虑建立虚拟COM,并通过它发送包含在CAN帧中的数据.可以吗?我怎么能在linux上建立虚拟COM?发现这个线程的虚拟串口Linux, 但遗憾的是我不知道如何将它实现到程序的源代码(linux下的初学linux用户和程序员).
很乐意阅读您的经验和建议.
我正在使用react native为iPhone编写小应用程序.我正在尝试使用fetch从网站获取JSON数据.就像在例子中:
function status(response) {
if (response.status >= 200 && response.status < 300) {
return response
}
throw new Error(response.statusText)
}
function json(response) {
return response.json()
}
fetch('/users', {
method: 'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Hubot',
login: 'hubot',
})
}).then(status)
.then(json)
.then(function(json) {
console.log('request succeeded with json response', json)
}).catch(function(error) {
console.log('request failed', error)
})
Run Code Online (Sandbox Code Playgroud)
一切正常,但我需要稍后使用这些数据.当我尝试将它分配给json函数中的某个变量时,我得到"请求错误",然后获取数据(正确).获取该数据并将其放入某个变量以便以后使用它的最佳做法是什么?
是否有解决方案来检测反应原生WebView上的任何位置?试图把它放在TouchableOpacity里面,但我收到了错误.是否有一些工作,检测点击?
我需要在会话之间存储一些用户数据,例如设置,登录,令牌等.尝试了异步存储,但是当我重新启动应用程序时,其中的数据将被删除.找到了一些引用钥匙串或NSUserDefaults的模块,但我不知道哪个模块和任何模块都有用.
主要功能是即使应用程序被杀死并重新启动后,我也可以获取该数据.主要是在iOS上,但如果它也在Andorid上,那就太好了.
有人有过一些经验吗?
编辑:
我尝试使用asyncstorage.但是当你杀死并重启应用程序时,它没有做任何事情.
我存储数据的代码:
AsyncStorage.setItem("prefix", responseData['prefix'])
AsyncStorage.setItem("api_token", responseData['api_token'])
Run Code Online (Sandbox Code Playgroud)
并检索数据:
async _checkAutoLogin(){
var prefix;
var token;
try {
prefix = await AsyncStorage.getItem("prefix");
token = await AsyncStorage.getItem("api_token");
} catch (error) {
AlertIOS.alert('AsyncStorage error: ' + error.message);
}
Run Code Online (Sandbox Code Playgroud) 我想将我的应用程序中的图像上传到S3服务器.我已经计算了所有数据和代码(在计算机上使用curl测试),但我无法弄清楚如何正确调用'fetch'.我得到回应:
'您指定的至少一个前提条件不成立.条件:Bucket POST必须是enclosure-type-multipart/form-data'
如何在react-natives fetch中重新创建表单数据?没有我可以附加的FormData,然后像在fetches示例中一样发送它.
编辑:谢谢@ philipp-von-weitershausen,请注意您已添加此功能.但是我有一些麻烦叫它.我得到"不支持的BodyInit类型".发现那是因为在fetch.js中:"support.formData"返回false.我打电话给fetch时我错过了什么?
我的代码示例:
var form = new FormData();
form.append("FormData", true)
form.append("name", this.state.invoiceNumber)
form.append("key", this.state.invoiceNumber)
form.append("Content-Type", "image/png")
form.append('file', this.props.uri)
//alert(FormData.prototype.isPrototypeOf(form))
fetch(amazon_url,{body: form,mode: "FormData", method: "post", headers: {"Content-Type": "multipart/FormData"}})
.then((response) => response.json())
.catch((error) => {
alert("ERROR " + error)
})
.then((responseData) => {
alert("Succes "+ responseData)
})
.done();
Run Code Online (Sandbox Code Playgroud) 我在Debian的Qt中构建应用程序时遇到问题.
当我尝试编译任何我得到的东西:
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
make: *** [test] Error 1
14:38:52: Proces "/usr/bin/make" zako?czy? si? kodem wyj?ciowym 2.
最后一行表示:Procces(...)
退出代码:2
知道什么是错的吗?