Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

Getting bytes from a memory that's dymanicly allocated.

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
Lillan061397
Asked:
Lillan061397
  • 7
  • 4
1 Solution
 
Lillan061397Author Commented:
Edited text of question
0
 
Lillan061397Author Commented:
Edited text of question
0
 
icampbe1Commented:
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
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!

 
icampbe1Commented:
Most of the conversion routines (at least in D3) do this internally already.
0
 
Lillan061397Author Commented:
Edited text of question
0
 
Lillan061397Author Commented:
Edited text of question
0
 
icampbe1Commented:
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
 
Lillan061397Author Commented:
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
 
icampbe1Commented:
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
 
Lillan061397Author Commented:
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
 
Lillan061397Author Commented:
Hi Ian!

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

Thanks for your help!

Linda.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now