Solved

Getting bytes from a memory that's dymanicly allocated.

Posted on 1997-07-18
11
171 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
  • 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

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

Accepted Solution

by:
icampbe1 earned 50 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now