I belive this is correct, however nothing happends when I send the packet,
(It is supposed to run a stepper motor).
Maybe the TAG_CMD etc. should be text (string)?
Main Topics
Browse All TopicsHello!
I have a Luminary Micro Controller where all code examples are written in C.
From their support I've been told that I need to open a COM port in Delphi and
send a packet of bytes to the microcontroller.
The C packet looks like this:
//
// Construct a set target position command.
//
g_pucData[0] = TAG_CMD;
g_pucData[1] = 0x09;
g_pucData[2] = CMD_SET_PARAM_VALUE;
g_pucData[3] = PARAM_TARGET_POS;
g_pucData[4] = g_ulTargetPosition & 0xff;
g_pucData[5] = (g_ ulTargetPosition >> 8) & 0xff;
g_pucData[6] = (g_ ulTargetPosition >> 16) & 0xff;
g_pucData[7] = (g_ ulTargetPosition >> 24) & 0xff;
g_pucData[8] = {checksum};
Bytes in the packet should be:
0xFF 0x09 0x13 0x08 0x00 0xC8 0x00 0x00 0x13
In Delphi I'm using a component called TSerialPortNG to open the COM port (COM3) and send data.
procedure SendData(Data: Pointer; Size: Cardinal);
Need help to define the Delphi/pascal record and add the byte values to it before sending.
Many thanks,
-B
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I'm monitoring the port while running a application that comes with the board and are able to
get all the bytes sent.
When I'm sending a packet, only 4 bytes are sent. (FF 09 13 08).
It seems that the other application is sending 3 packets to have the motor running:
(the second byte tells the length of the packet)
FF 09 13 08 00 F4 01 00 E8
FF 04 30 CD
FF 09 13 08 00 F4 01 00 E8
Business Accounts
Answer for Membership
by: mokulePosted on 2008-10-24 at 17:13:04ID: 22801018
var
pack: packed array[0..8] of byte;
p: pointer;
begin
pack[0] := $FF;
pack[1] := $09;
// and so on
p := @pack;