Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Getting bytes from a memory that's dymanicly allocated.

Posted on 1997-07-18
11
Medium Priority
?
184 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

609 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