- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您好,首先感谢您阅读我的问题!
我有一个设备,它给我的输出基本上只是一个 RS232 串行信号(1200 波特、8 个数据位、无奇偶校验位、一个停止位)。此输出通过 3.5 毫米音频插孔进入我的 Android 手机。
我想将每个数据位存储到一个变量中,显示或计算一些东西,当下一个位进来时,它应该覆盖变量。
在我将数据位放入变量中后,我确切地知道如何处理它,但我不知道如何进行基本输入/流/从音频插孔读取...
我找到了这个,但对我帮助不大:Android serial port via audio jack也许是这样的:Android: Need to record mic input
请帮帮我,谢谢!
编辑:关于我的信号的更多信息有效负载以 9 字节数据包的形式传输:
1: command byte as ASCII character ('I','A','S','L','R','C' or ' ')
2-6: time in ASCII chars (2:34:56)
7: checksum (64 + sum of time digits)
8: CR (carriage return, ASCII code 0x0D)
9: LF (line feed, ASCII code 0x0A)
Edit2:我还认为我必须将输入存储到缓冲区中,然后从缓冲区中读取信号...但是如何将音频插孔的串行输入写入缓冲区?
Edit3:也许这样的事情会奏效:
try
{
int N = AudioRecord.getMinBufferSize(8000,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT);
recorder = new AudioRecord(AudioSource.MIC, 1200, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, N*10);
track = new AudioTrack(AudioManager.STREAM_MUSIC, 1200,
AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, N*10, AudioTrack.MODE_STREAM);
recorder.startRecording();
track.play();
/*
* Loops until something outside of this thread stops it.
* Reads the data from the recorder and writes it to the audio track for playback.
*/
while(!stopped)
{
Log.i("Map", "Writing new data to buffer");
short[] buffer = buffers[ix++ % buffers.length];
N = recorder.read(buffer,0,buffer.length);
track.write(buffer, 0, buffer.length);
}
}
catch(Throwable x)
{
Log.w("Audio", "Error reading voice audio", x);
}
/*
* Frees the thread's resources after the loop completes so that it can be run again
*/
finally
{
recorder.stop();
recorder.release();
track.stop();
track.release();
}
}
最佳答案
虽然不是您问题的详细答案,但您当前的方法存在许多问题
您违反了 Nyquist sampling theory通过以线路速率对输入信号进行采样。您的系统带宽需要至少是比特率的两倍。
您目前似乎无法构建您的消息以指示消息在字节流中开始或结束。特别是,0x0a
和 0x0d
都可能出现在消息正文的其他位置。您可能会考虑使用每个字节的 MSB 来信号帧,并且只在每个字节的剩余 7 位中编码有效负载)
您正在尝试在没有时钟恢复的情况下对信号进行采样。发送方发送时钟和接收方的采样时钟不同步——也就是说时钟边沿不对齐。它们可能会随着时间的推移而漂移。
此外,您需要注意信号电平 - RS232 可能在 12v 时发出信号。
这是一个已经很好解决的问题 - 我建议查看一些调制解调器标准。某种调制 - 例如 Phase Shift Keying通常与某种时钟恢复一起使用以处理上述问题 1 和 3。
关于android - android智能手机3.5mm音频口RS232串口信号输入(android开发),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19383890/
我正在尝试使用这两种格式解析日期 2014-12-03T10:05:59.5646+08:00: yyyy-MM-dd'T'HH:mm:ss yyyy-MM-dd'T'HH:mm:ssXXX 当我使用
Paypal 返回以下格式的时间戳: yyyy-MM-ddTHH:mm:ssZ 我不知道该怎么办... 如何在 php 中使用本地时区将其转换为 yyyy-MM-dd HH:mm:ss? 我很想pre
我正在使用 Excel 2010 或 Excel 2007 导入包含日期/时间信息的 CSV 文件。我的 CSV 文件中的时间戳具有以下格式:yyyy-mm-dd hh:mm:ss。 (例如:2015
这个问题已经有答案了: Separate Date and Time objects (2 个回答) 已关闭 4 年前。 如何从 SimpleDateFormat("MM/dd/yyyy kk:mm"
这个问题已经有答案了: Java string to date conversion (17 个回答) 已关闭 6 年前。 我需要将日期字符串转换为另一种特定格式。 例如:我有一个日期,可以是 YYY
我想将字符串:24/11/2016 04:30 pm 转换为日期时间值:11/24/2016 04:30 pm。 我的代码为: DateTime date = DateTime.ParseExact(
我想使用 linux 将像“26/11/05 06:00:01,057000000”这样的纪元转换为 yyyy-mm-ddThh:mm:ss? 我曾尝试使用以下脚本但没有成功: echo 26/11/
这个问题在这里已经有了答案: mysql YYYY-MM-DDThh:mm:ss (1 个回答) 关闭 6 年前。 我想上传包含 yyyy-mm-ddThh:mm:ss.sssZ 数据的 csv 文
我在“dd-MM-yyyy HH:mm”中有一个字符串,需要将其转换为格式为日期的对象“yyyy-MM-dd HH:mm”。 下面是我用来转换的代码 oldScheduledDate = "16-05
我有一个数据框(df),它有一个日期列(列名:sale_date),它以以下格式存储数据 dd/mm/yy hh:mm:ss 我正在尝试将其转换为 yyyy-mm-dd hh:mm:ss。尝试了以下但
我的数据库中有日期时间列(格式为 YYYY-mm-dd hh:mm:ss)。 我需要将其转换为 dd-mm-YYYY hh:mm:ss 格式。 我该怎么办?帮助我。 最佳答案 不确定如何在 javas
想知道它们是否代表不同的格式或本质上相同(只是新与旧的演示文稿)。 最佳答案 基于DateTimeFormatter : Offset X and x: This formats the offset
如标题所示,我有一个问题。我需要将 LocalDataTime yyyy-MM-ssThh-mm-ss 解析为 LocalDataTime yyyy-MM-ss hh-mm-ss 但是当我这样做时 S
我想用 mySQL 将我的数据从“yyyy-mm-ddThh-mm-ss.sssZ”转换为“yyyy-mm-dd hh-mm-ss”。 我尝试使用 convert_tz: mysql> SELECT
这个问题在这里已经有了答案: LOAD DATA INFILE easily convert YYYYMMDD to YYYY-MM-DD? (1 个回答) 关闭 6 年前。 我正在尝试将 CSV
我需要更改 string 的日期格式。原始字符串的格式如下: var timeStamp = '2014/07/30 - 14:15:36' 这是我想要实现的日期格式: var timeStampAr
我正在尝试将 yyyy-MM-dd'T'HH:mm:ss.SSSz 格式的日期格式化为 yyyy-mm-dd HH:mm:ss,这应该很容易,但我无法获得它可以工作。 需要解析的日期格式为:2012-
我正在尝试通过传递时间戳作为命令行参数来使用 Synapse 管道运行 Spark 作业。在与 Spark 作业相关的代码运行之前,synapse 正在将字符串命令行参数值从 ISO 格式 2019-
我试过下面的代码: String created_Date = "25-Nov-15 14:23:34"; SimpleDateFormat sdf = new SimpleDateFormat("d
我创建了一个函数,它以与原始格式不同的格式返回日期。基本上,我正在使用此 Select MonthSub('2014-04-10',2)# 语句进行测试,它应该返回2014-02,而不是 2014-0
我是一名优秀的程序员,十分优秀!