Adobe Air 和串行端口与 Serproxy/Thinkerproxy 的通信
我在小型 Air 应用程序中使用 serproxy / thinkerproxy 进行串行通信。 我有两个硬件设备来测试它。一个是条形码扫描仪,它工作得很好。
另一种是定制板。这也是一种工作。问题是字符不可读。我认为这是字符集的问题(不确定),所以我在处理 ProgressEvent.SOCKET_DATA 事件的函数中尝试了类似的操作:
var cs:Array = new Array( 'ISO-8859-1',
'ISO-8859-2',
'ISO-8859-3',
'ISO-8859-4',
'ISO-8859-5',
'ISO-8859-6',
'ISO-8859-7',
'ISO-8859-8',
'ISO-8859-9',
'ISO-8859-10',
'ISO-8859-11',
'ISO-8859-12',
'ISO-8859-13',
'ISO-8859-14',
'ISO-8859-15',
'ISO-8859-16',
'ISO-8859-17',
'ISO-8859-18',
'ISO-8859-19',
'ISO-8859-20',
'ASMO-708',
'DOS-720',
'x-mac-arabic',
'windows-1256',
'ibm775',
'windows-1257',
'ibm852',
'x-mac-ce',
'windows-1250',
'gb18030',
'EUC-CN',
'gb2312',
'gb18030',
'hz-gb-2312',
'x-mac-chinesesimp',
'big5',
'x-Chinese-CNS',
'x-Chinese-Eten',
'x-mac-chinesetrad',
'cp866',
'koi8-r',
'koi8-u',
'x-mac-greek',
'windows-1253',
'ibm869',
'DOS-862',
'iso-8859-8-i',
'x-mac-hebrew',
'windows-1255',
'x-EBCDIC-Arabic',
'x-EBCDIC-CyrillicRussian',
'x-EBCDIC-CyrillicSerbianBulgarian',
'x-EBCDIC-DenmarkNorway',
'x-ebcdic-denmarknorway-euro',
'x-EBCDIC-FinlandSweden',
'x-ebcdic-finlandsweden-euro',
'x-ebcdic-finlandsweden-euro',
'x-iscii-as',
'unicode',
'unicodeFFFE',
'utf-7',
'utf-8',
'us-ascii',
'windows-1258',
'x-IA5',
'Windows-1252'
);
for each(var csStr:String in cs){
var info:String = _socket.readMultiByte(_socket.bytesAvailable, csStr);
temp = csStr + ":" + info;
if(info.length > 0)
dispatchEvent(new TextEvent(EVENT_ON_DATA_RECEIVED, false, false, temp) );
}
包含值的唯一值是 ISO-8859-1。它看起来像这样:
自定义板应该发送类似以下内容的内容:0x40< /strong>
所以,不确定这里最好的方法是什么(我知道我可以尝试更多的字符集)。有什么想法吗?
I'm using serproxy / thinkerproxy for serial communication in a small Air app.
I have two hardware devices to test it. One is a barcode scanner, it works perfectly.
The other is a custom board. It's kind of working also. The problem is that the characters are unreadable. I think it's a problem of charset (not sure) so I tried something like this in the function that handles the ProgressEvent.SOCKET_DATA event:
var cs:Array = new Array( 'ISO-8859-1',
'ISO-8859-2',
'ISO-8859-3',
'ISO-8859-4',
'ISO-8859-5',
'ISO-8859-6',
'ISO-8859-7',
'ISO-8859-8',
'ISO-8859-9',
'ISO-8859-10',
'ISO-8859-11',
'ISO-8859-12',
'ISO-8859-13',
'ISO-8859-14',
'ISO-8859-15',
'ISO-8859-16',
'ISO-8859-17',
'ISO-8859-18',
'ISO-8859-19',
'ISO-8859-20',
'ASMO-708',
'DOS-720',
'x-mac-arabic',
'windows-1256',
'ibm775',
'windows-1257',
'ibm852',
'x-mac-ce',
'windows-1250',
'gb18030',
'EUC-CN',
'gb2312',
'gb18030',
'hz-gb-2312',
'x-mac-chinesesimp',
'big5',
'x-Chinese-CNS',
'x-Chinese-Eten',
'x-mac-chinesetrad',
'cp866',
'koi8-r',
'koi8-u',
'x-mac-greek',
'windows-1253',
'ibm869',
'DOS-862',
'iso-8859-8-i',
'x-mac-hebrew',
'windows-1255',
'x-EBCDIC-Arabic',
'x-EBCDIC-CyrillicRussian',
'x-EBCDIC-CyrillicSerbianBulgarian',
'x-EBCDIC-DenmarkNorway',
'x-ebcdic-denmarknorway-euro',
'x-EBCDIC-FinlandSweden',
'x-ebcdic-finlandsweden-euro',
'x-ebcdic-finlandsweden-euro',
'x-iscii-as',
'unicode',
'unicodeFFFE',
'utf-7',
'utf-8',
'us-ascii',
'windows-1258',
'x-IA5',
'Windows-1252'
);
for each(var csStr:String in cs){
var info:String = _socket.readMultiByte(_socket.bytesAvailable, csStr);
temp = csStr + ":" + info;
if(info.length > 0)
dispatchEvent(new TextEvent(EVENT_ON_DATA_RECEIVED, false, false, temp) );
}
The only value that contains a value is ISO-8859-1. and and it looks like this:
The custom board is supposed to send something like : 0x40
So, not sure what is the best approach here (I know there are more charset I can try). Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否想猜测未知的编码?查看板发送的原始字节以检查它们是否已移位。
Are you trying to guess unknown encoding? Look at raw bytes that board sends to check whether they are bit-shifted.
您检查过您的设置吗?我怀疑奇偶校验位的设置不同。
Have you checked your settings - I'd suspect differing settings for parity bit.