472,779 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 software developers and data experts.

Problem With Extended ASCII processing.

Hi All,

I am new to C# programming; I am developing an application for recording
audio data using voice modem.
I am using HyperTerminal to manually process audio data. The modem when
configured in voice record mode sends the audio (PCM) data on the serial
port, few of the characters from these are in Extended ASCII range i.e. more
than 127 decimal.
In HyperTerminal we can reset the property to force the incoming data to 7
bit ASCII, i.e. by un-checking this option we can record the Extended ASCII
also.
When I am using the C# application I am reading from serial port using
serialPort1.ReadExisting () --- this returns the complete received string or
serialPort1.Read(recevBuff, 0, buffLength)---- this returns received
characters in the recevBuff. The problem is by using both these methods the
extended ASCII characters are rounded off automatically to 7 bit ASCII and I
get the wrong response. I have even tried using the Encoding class with
Encoding.Default property but this does not give me the correct corresponding
Extended ASCII character in the response.
I have a plan to store this received data to a file but things are not
working due to this conversion problem. Can anybody help?

Thanks & Regards
Roshan.

Oct 9 '07 #1
4 7139
On Oct 9, 9:44 am, Roshan R.D <Rosha...@discussions.microsoft.com>
wrote:
I am new to C# programming; I am developing an application for recording
audio data using voice modem.
I am using HyperTerminal to manually process audio data. The modem when
configured in voice record mode sends the audio (PCM) data on the serial
port, few of the characters from these are in Extended ASCII range i.e. more
than 127 decimal.
There's no such thing as "Extended ASCII". Or rather, there are
various encodings which use ASCII for the first 127 values, but which
do different things

However, you shouldn't be using text at all to receive *binary* data
(such as audio). You should be reading *bytes*, not characters. Pass a
byte array into Read instead of a char array and things are likely to
start working.

Jon
Oct 9 '07 #2
Hello Jon,

Thanks for your reply; My problem is solved now I am able to convert the
response bytes to proper Extended ASCII characters. I have used
System.Text.ASCIIEncoding.Default.GetString(recBuf fer) property to convert to
Ext ASCII.
I was actually using bytes array to read from serial port, then I am
converting it to string using the above method. I am doing this to remove
'\0', '\r', and '\n' characters from the incoming string to get a disturbance
free response.

Regards
Roshan

"Jon Skeet [C# MVP]" wrote:
On Oct 9, 9:44 am, Roshan R.D <Rosha...@discussions.microsoft.com>
wrote:
I am new to C# programming; I am developing an application for recording
audio data using voice modem.
I am using HyperTerminal to manually process audio data. The modem when
configured in voice record mode sends the audio (PCM) data on the serial
port, few of the characters from these are in Extended ASCII range i.e. more
than 127 decimal.

There's no such thing as "Extended ASCII". Or rather, there are
various encodings which use ASCII for the first 127 values, but which
do different things

However, you shouldn't be using text at all to receive *binary* data
(such as audio). You should be reading *bytes*, not characters. Pass a
byte array into Read instead of a char array and things are likely to
start working.

Jon
Oct 9 '07 #3
On Oct 9, 11:50 am, Roshan R.D <Rosha...@discussions.microsoft.com>
wrote:
Thanks for your reply; My problem is solved now I am able to convert the
response bytes to proper Extended ASCII characters. I have used
System.Text.ASCIIEncoding.Default.GetString(recBuf fer) property to convert to
Ext ASCII.
That's a really bad way of doing it. There's no need for a text
conversion to start with, as far as I can see.
I was actually using bytes array to read from serial port, then I am
converting it to string using the above method. I am doing this to remove
'\0', '\r', and '\n' characters from the incoming string to get a disturbance
free response.
But voice data isn't text data to start with, surely - there shouldn't
be an "incoming string" there should just be incoming binary data.

Jon

Oct 9 '07 #4
Hi,

You should use the Read method for binary data. ReadExisting should be used
only with ASCII - text. Use an array of type Byte to buffer receive data.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Oct 9 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: | last post by:
Hey all, Quick question...been bugging me for some time, really. I have a console app, it does some things, and I want to save an array of text to a text file. The text consists of ASCII and...
7
by: john | last post by:
On my form i have a message box called txtItemDesc that displays the french phrase qualité Père Noël. Now then when i run this code on that text box: Dim chrArr() As Char chrArr =...
8
by: timtos | last post by:
I want to save text in a file and after that I want to display this textfile using the internet explorer. If I am displaying "html text" everything is fine but if I want to display plain text...
4
by: wob | last post by:
Many thanks for those who responded to my question of "putting greek char into C string". In searching for an solution, I noticed that there are more than one version of "Extended ASCII...
1
by: Blent stn | last post by:
Hi, im trying to upload somefiles using sockets to a FTP site. But i've some problems with extended ascii characters. When i try "MKD blent" the created folder is "blent". The directory name is...
5
by: Lenard Gunda | last post by:
hi! I have the following problem. I need to read data from a TXT file our company receives. I would use StreamReader, and process it line by line using ReadLine, however, the following problem...
3
by: JSM | last post by:
Hi, I am just trying to port an existing simple encryption routine to C#. this routine simply adds/substracts 10 ascii characters to each character in a text file (except quotes). The routine...
1
by: s123 | last post by:
Hi, while invoking a web service, if in xml request message i wrap the extended ASCII characters with CDATA it is not returning the desired result, while this is not the case if i do not wrap...
13
by: ramif | last post by:
Is there a way to print extended ASCII in C?? I tried to code something, but it only displays strange symbols. here is my code: main() { char chr = 177; //stores the extended ASCII...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.