Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming
The ASP Free website provides in-depth information on the latest developer tools available from Microsoft. Our cadre of writers, highly experienced industry experts, reveals the best ways to use established technologies as well as new and emerging technologies. Our coverage of Microsoft's development and administration technologies is among the most respected in the IT industry today.

ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Download and Activate to enter!

Intel® Graphics Performance Analyzers is a powerful tool suite for analyzing and optimizing your games, media, and graphics-intensive applications. Used by some of the best developers on the planet, Intel GPA lets you maximize your app’s performance.


Tutorials
| Forums

Download to Enter
| Contest Rules

DOWNLOAD INTEL® GPA FOR FREE

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 6th, 2009, 08:20 AM
riggd riggd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 3 riggd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 44 m 12 sec
Reputation Power: 0
Incompatible types: Array and PAnsiChar

I am trying to compile some example code, usb_cdc shown below, from sixca.com

After installing the TComPort component, required, and compiling I get an error message at Line 45: Incompatible types: 'Array' and 'PAnsiChar'

The error points to this line in red below: ComPort1.Read(InBuffer,2);

Can someone please explain or help with a solution?

Thanks
Don



unit main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, CPort, ComCtrls;

type
TForm1 = class(TForm)
ComPort1: TComPort;
Edit1: TEdit;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
Label1: TLabel;
ProgressBar1: TProgressBar;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure ComPort1RxChar(Sender: TObject; Count: Integer);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
Out_Buffer:char;

implementation

{$R *.dfm}

procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer);
var InBuffer:array[0..1] of byte;
ADC_Hi,ADC_lo:byte;
ADCRes:word;
volt:double;
begin
ComPort1.Read(InBuffer,2);
ADC_Hi:=InBuffer[0];
ADC_Lo:=InBuffer[1];
ADCRes:=(ADC_Hi shl 8) or ADC_Lo;
Volt:=(5*ADCRes)/$3FF;
edit1.Text:=FloatToStrF(Volt,ffFixed,3,2);
Progressbar1.Position:=round((100*ADCRes)/$3FF);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Comport1.Open;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Comport1.Close;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked then
ComPort1.WriteStr('1')
else
ComPort1.WriteStr('2');
end;

procedure TForm1.CheckBox2Click(Sender: TObject);
begin
if CheckBox2.Checked then
ComPort1.WriteStr('3')
else
ComPort1.WriteStr('4');
end;

end.

Reply With Quote
  #2  
Old August 6th, 2009, 09:56 AM
murklys murklys is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2008
Posts: 496 murklys User rank is Second Lieutenant (5000 - 10000 Reputation Level)murklys User rank is Second Lieutenant (5000 - 10000 Reputation Level)murklys User rank is Second Lieutenant (5000 - 10000 Reputation Level)murklys User rank is Second Lieutenant (5000 - 10000 Reputation Level)murklys User rank is Second Lieutenant (5000 - 10000 Reputation Level)murklys User rank is Second Lieutenant (5000 - 10000 Reputation Level)murklys User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 21 h 59 m 29 sec
Reputation Power: 86
Can't say for sure, but you may try two things that won't kill you and might help:

maybe:
Code:
ComPort1.Read(InBuffer^,2);


or maybe:
Code:
var InBuffer:array[0..1] of CHAR;


or a combination of both

Can't give any guarantee any of this will work, but won't hurt to try.

Reply With Quote
  #3  
Old August 6th, 2009, 01:18 PM
clivew clivew is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2006
Location: Carlsbad, CA
Posts: 1,802 clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 49 m 17 sec
Reputation Power: 296
Try
Code:
ComPort1.Read(InBuffer[0],2);


Clive

Reply With Quote
  #4  
Old August 7th, 2009, 06:35 AM
riggd riggd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 3 riggd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 44 m 12 sec
Reputation Power: 0
Sorry guys but none of those ideas worked...

Reply With Quote
  #5  
Old August 7th, 2009, 09:39 AM
murklys murklys is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2008
Posts: 496 murklys User rank is Second Lieutenant (5000 - 10000 Reputation Level)murklys User rank is Second Lieutenant (5000 - 10000 Reputation Level)murklys User rank is Second Lieutenant (5000 - 10000 Reputation Level)murklys User rank is Second Lieutenant (5000 - 10000 Reputation Level)murklys User rank is Second Lieutenant (5000 - 10000 Reputation Level)murklys User rank is Second Lieutenant (5000 - 10000 Reputation Level)murklys User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 21 h 59 m 29 sec
Reputation Power: 86
Damn it works with streams so what's with this com port thing ... hm ... Maybe there is a method like ReadChar there? You could use it two times to read a character in the worst case. You could probably define the buffer as PChar and Read(p^, 2) or is it Read(p, 2) ... but i'm not sure how you would get the bytes out of that damn pchar after that.

Reply With Quote
  #6  
Old August 7th, 2009, 12:30 PM
clivew clivew is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2006
Location: Carlsbad, CA
Posts: 1,802 clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level)clivew User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 49 m 17 sec
Reputation Power: 296
Did you try?
Code:
var InBuffer:array[0..1] of AnsiChar;
  
ComPort1.Read(InBuffer[0],2);


or maybe
Code:
var InBuffer:array[0..1] of AnsiChar;
  
ComPort1.Read(pAnsiChar(InBuffer[0]),2);

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > Incompatible types: Array and PAnsiChar


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap