?
Solved

Getting bytes from a memory that's dymanicly allocated.

Posted on 1997-07-18
11
Medium Priority
?
179 Views
Last Modified: 2010-04-06
Hi!
Here is what I'm working with:
Buffpointer: Pointer;

GetMem( BuffPointer, 2048 );
ReadFile(hComm, BuffPointer^, 10, NbrRead, @overlappedRead)

The ReadFile is reading from the serial communications-port with a baudrate at 115200, and I know that the other computer is sending bytes containing information from an A/D-converter. Therefore I want to get the value on every byte(0 - 255) so I then can use it to draw a curve on the screen.

 If I do PChar(BuffPointer) the result is in Char and the information that I want is lost. Maybe You have another idea on how I should do?
Thanks!

Regards Linda.
0
Comment
Question by:Lillan061397
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
11 Comments
 

Author Comment

by:Lillan061397
ID: 1339137
Edited text of question
0
 

Author Comment

by:Lillan061397
ID: 1339138
Edited text of question
0
 
LVL 2

Expert Comment

by:icampbe1
ID: 1339139
Hi Linda,

Maybe if you tell more about your task.  Are you trying to read the file to get character pairs and then use these pairs to create a Unicode (Like Swedish) string ??

 Also, when you say holes in the ASCII chart, I assume you mean the values above 127.

Ian C.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Expert Comment

by:icampbe1
ID: 1339140
Most of the conversion routines (at least in D3) do this internally already.
0
 

Author Comment

by:Lillan061397
ID: 1339141
Edited text of question
0
 

Author Comment

by:Lillan061397
ID: 1339142
Edited text of question
0
 
LVL 2

Accepted Solution

by:
icampbe1 earned 200 total points
ID: 1339143
Use a typed pointer.

VAR
    BuffPointer: ^BYTE;

Type BYTE is just 8 bits of binary storage.  It does not have a Char personality.  Also, make sure to set up the Com port for binary transfers.

Ian C.

0
 

Author Comment

by:Lillan061397
ID: 1339144
Hi Ian!

I hope the editing of the question is better. If a bytes value is 97 I want to be able to get 97 as an integer and not an 'a'. I'm using this to draw a curve. Is this possible? I hope so!!

Regards Linda.
0
 
LVL 2

Expert Comment

by:icampbe1
ID: 1339145
Yes, use BYTE not CHAR.  A type of BYTE doesn't know about 'a' or 'b'.  It just is 8 binary bits of storage.  If you want it as a signed integer, use SHORTINT.

BYTE and SHORTINT are the 8 bit equivalents of WORD and INTEGER.

Does this help?

Ian C.
0
 

Author Comment

by:Lillan061397
ID: 1339146
Hi again!

I can only get the first byte! How do I do to get the second and so on? Otherwise it's working.

Regards
Linda.
0
 

Author Comment

by:Lillan061397
ID: 1339147
Hi Ian!

After about 10 sec I figured out how to read all the bytes!

Thanks for your help!

Linda.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month11 days, 15 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question