Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 23, 2014, 09:33:33 09:33


Login with username, password and session length


Pages: [1]
Print
Author Topic: sent binary to commport mscomm.output:=chr(x:byte); using delphi ?  (Read 2637 times)
0 Members and 1 Guest are viewing this topic.
waicon
Active Member
***
Offline Offline

Posts: 120

Thank You
-Given: 49
-Receive: 49


I'm learning to Dream...not just Relaxing...zzZ


« on: January 30, 2010, 02:41:31 02:41 »

how to sent binary byte to comport using delphi ? are mscomm.output only can sent byte from 0 to 80 ?  
have try on
Code:
var
senddata:chr;
begin
mscomm.output:=chr(senddata);  //*** where senddata only valid from 0~80 , above chr(80) will be receive wrong byte--->3F

edit---
I did a loop back test on
mscomm1.output:=chr(i);  //*** where i=0 to 255
Code:
Received:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
3F 81 3F 3F 3F 3F 3F 3F 3F 3F 3F 3F 3F 8D 3F 8F
90 3F 3F 3F 3F 3F 3F 3F 3F 3F 3F 3F 3F 9D 3F 3F
A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF
B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF
F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
some bytes are missing and replaced by 3F, what's going on Huh

« Last Edit: January 30, 2010, 11:10:49 11:10 by waicon » Logged
flyback
V.I.P
Junior Member
*****
Offline Offline

Posts: 66

Thank You
-Given: 44
-Receive: 20


« Reply #1 on: January 31, 2010, 07:13:27 19:13 »

I understand that "80" means 80h (80 hex = 128 decimal)

I saw that 00 is not received. this is a NULL char, and many communication packages ignore it.

The range from 80h to 9Fh suffer from this behaviour: if you strip the MSBit, il will be mapped
to 0.. 1F which are the non printable chars.

May you try to change
    var senddata:chr   (<=== I don't remember that there are ''chr'' type in 'V'B, it isn't ''char'' ?)
to
    var senddata:byte

and see what happens?
 

Posted on: January 31, 2010, 07:11:24 19:11 - Automerged

Just sorry, I wrote VB instead of Delphi
Logged
SONSiVRi
Administrator
Hero Member
*****
Offline Offline

Posts: 1428

Thank You
-Given: 69
-Receive: 377



WWW
« Reply #2 on: January 31, 2010, 07:42:49 19:42 »

There is no chr datatype in Delphi.
Quote
senddata:chr;
Logged

- Houston, we have a problem.
waicon
Active Member
***
Offline Offline

Posts: 120

Thank You
-Given: 49
-Receive: 49


I'm learning to Dream...not just Relaxing...zzZ


« Reply #3 on: February 01, 2010, 03:02:10 03:02 »

YES!!!. it works now Grin , some differant in delphi2009 and delphi2007 in defind var in char.
Quote
var
senddata:array[1..300] of ansichar;
...
begin
...
for i=0 to 255 do
mscomm1.output:=ansichar(senddata);  //*** where i= inc from 0~ 255 ***//
...
default char in ascii code in computer various by OS; language, i read some book said that
ASC, JIS code as below: 00~ 7F than to A0~DF some char missing or not defind.

received code
Quote
 for i:=0 to vararrayhighbound(redata,1) do
  restr:=restr + inttohex(redata,2)+' ';
  memo1.Text:=memo1.Text+restr;

interupt on receive demand code
Quote
receive on demand code
procedure TForm1.MSComm1Comm(Sender: TObject);   //**RThreshold set =1 ***??
  begin
    case mscomm1.CommEvent of
         comEvReceive:          bzw := true;
  end;
end;
this is my first delphi program  Grin Grin
 
« Last Edit: February 01, 2010, 03:08:38 03:08 by waicon » Logged
waicon
Active Member
***
Offline Offline

Posts: 120

Thank You
-Given: 49
-Receive: 49


I'm learning to Dream...not just Relaxing...zzZ


« Reply #4 on: February 01, 2010, 07:36:21 07:36 »

ok. lets go further  Grin Grin Grin
my next step is to understand RS485 protocol.
dataframe structure package as below:

PACKAGE:
--------
START_BYTE 0x96
ADDRESS
DATALEN
[DATA1]           
[DATA2]         
[DATA3]         
CRC
STOP_BYTE  0xA9
*************************
DATALEN bits
------------
bit7 = 1  MASTER SENDS
       0  SLAVE  SENDS
bit6 = 1  ADDRESS WAS XORed with 1, IT WAS EQUAL TO _START_BYTE or _STOP_BYTE
      = 0  ADDRESS UNCHANGED
bit5 = 0  FIXED
bit4 = 1  DATA3 (if exists) WAS XORed with 1, IT WAS EQUAL TO _START_BYTE or _STOP_BYTE
      = 0  DATA3 (if exists) UNCHANGED
bit3 = 1  DATA2 (if exists) WAS XORed with 1, IT WAS EQUAL TO _START_BYTE or _STOP_BYTE
      = 0  DATA2 (if exists) UNCHANGED
bit2 = 1  DATA1 (if exists) WAS XORed with 1, IT WAS EQUAL TO _START_BYTE or _STOP_BYTE
      = 0  DATA1 (if exists) UNCHANGED
bit1bit0 = 0 to 3 NUMBER OF DATA BYTES SEND


Q1: any guide for "XOR-ed with 1" ; how to XOR 1 byte with 1 in delphi ?
Q2: how to cal. CRC in 8bit in this dataframe ?
 
 
Logged
waicon
Active Member
***
Offline Offline

Posts: 120

Thank You
-Given: 49
-Receive: 49


I'm learning to Dream...not just Relaxing...zzZ


« Reply #5 on: February 02, 2010, 04:53:03 16:53 »

completed this dataframe structure program, this my sec delphi program.
http://rapidshare.com/files/344868394/mscomm.rar
Logged
Alienbeing
Active Member
***
 Muted
Offline Offline

Posts: 167

Thank You
-Given: 68
-Receive: 45


« Reply #6 on: February 02, 2010, 09:31:04 21:31 »

Why don't you just use nrcomm in delphi? I had serial communications up and running in just acouple minutes using it. Try looking here
for more info http://www.sonsivri.com/forum/index.php?topic=22472.0
It was fast and easy to use. Especially works great with the FTDI R232 USB to RS232 chip.

Alienbeing
Logged
waicon
Active Member
***
Offline Offline

Posts: 120

Thank You
-Given: 49
-Receive: 49


I'm learning to Dream...not just Relaxing...zzZ


« Reply #7 on: February 03, 2010, 10:43:03 10:43 »

great tools, have downloaded nrComm_Lib_Pro_8.27(cracked) , but how to install it  Huh  i'm new to RAD delphi(any version) , i start to learn this 3 weeks ago. current using delphi2009, any guide ?
Logged
Alienbeing
Active Member
***
 Muted
Offline Offline

Posts: 167

Thank You
-Given: 68
-Receive: 45


« Reply #8 on: February 03, 2010, 01:05:50 13:05 »

 It can be confusing but is actually pretty easy. I'm using delphi 2007 so I'm not sure how much changed between the versions and if it will be compatable with your version. You might want to check the authors of that component's website to see if that version of that component will work with your version of delphi. They may also give instructions on how to install it into delphi. I know how but check them first. If they don't give instructions I'll see if I can write something up.

Alienbeing
Logged
waicon
Active Member
***
Offline Offline

Posts: 120

Thank You
-Given: 49
-Receive: 49


I'm learning to Dream...not just Relaxing...zzZ


« Reply #9 on: February 03, 2010, 04:29:50 16:29 »

great, i've delphi2007 manual pdf book, just explain how u did reg in delphi2007. Cheesy

the way i reg mscomm without installation package (shortcut Undecided) :-
at VB6 installer looking for below files:-
Mscomm.reg, Mscomm32.ocx, Mscomm32.dep, MSCOMM.SRG,
copy 4 files into windows/system32/, then use regsvr32 Mscomm32.ocx to reg. service,
double click on mscomm.reg (under admin),

at delphi --->component-->-->add component-->delphi VCL-->Import ActiveX Control-->Microsoft Comm Control 6.0--> install

it have telephone icon at VCL tool palette.
Logged
Alienbeing
Active Member
***
 Muted
Offline Offline

Posts: 167

Thank You
-Given: 68
-Receive: 45


« Reply #10 on: February 04, 2010, 06:30:14 06:30 »

OK, this is pretty simple.
Extract the contents of file to some directory. You should see several folders in that directory. Copy the folder that is labeled "DelphiCB12" (for Delphi 2009) to someplace where you keep your source code files.

Me I put my packages into C:\Program Files\CodeGear\RAD Studio\5.0\source\.
So because I use an older version of delphi (2007) I copied my folder here C:\Program Files\CodeGear\RAD Studio\5.0\source\DelphiCB11. I have to use the DelphiCB11 for delphi 2007.

You will use DelphiCB12 for version 2009 you have.

Now all you have to do next is start delphi and go to top menu "Component" and choose "Install Packages".
Click "Add" button. You will be asked for the package to install so point it to the folder DelphiCB12 (where ever you copied it too) and pick the file called nrcommd12.bpl click "open". Then "OK". And your done. Your new components should be installed now.


Alienbeing
Logged
waicon
Active Member
***
Offline Offline

Posts: 120

Thank You
-Given: 49
-Receive: 49


I'm learning to Dream...not just Relaxing...zzZ


« Reply #11 on: February 04, 2010, 03:05:56 15:05 »

great . it works. installed.


edit....
i found nrComm Lib v8.30(cracked). lucky day
« Last Edit: February 04, 2010, 09:05:52 21:05 by waicon » Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC