Cimplicity HMI Custom Communicaton Driver

glenglen

Member
Join Date
May 2003
Posts
24
hi everyone,

Im writing the custom communication driver for RFID currently. Im facing some problem while im running the cimplicity hmi and observing points. i've checked out that the code :

memcpy (data, &rx_buf[0], 10);

data in rx_buf:
rx_buf[0] = 0xAA
rx_buf[1] = 0x05
rx_buf[2] = 0x00
rx_buf[3] = 0x41
rx_buf[4] = 0x00
rx_buf[5] = 0x42
rx_buf[6] = 0x00
rx_buf[7] = 0x43
rx_buf[8] = 0x00
rx_buf[9] = 0x44 .... etc

the rx_buf is copied into the DOMAIN0 and my domain address is set as DOMAIN0 (TEXT - STRING_80) as well. but i found out that jus 2 characters are displaying on the point control panel which are "AAH" & "05H" only. can anyone tell me wats happpened? thank you very much.

below is my code, Visual C++.Net.

#include <stdio.h>
#include <inc_path/toolkit.h>

#define MSG_BEGIN 0xAA
#define MSG_TERM 0xFF
#define BLK_READ 0x05
#define TIMEOUT_MSB 0x07
#define TIMEOUT_LSB 0xD0
#define DATA_SIZE_MSB 0x00
#define DATA_SIZE_LSB 0x05
#define START_ADDR_MSB 0x00
#define START_ADDR_LSB 0x00

char ReadByte(void);
void WriteByte(char data);

HANDLE port_handle;

/***************************************************************************
* Read data from the specified device from the provided address
* for the length data, putting the data into the buffer data
****************************************************************************/

void TOOLKIT_CALL user_read_data (device_struct, address_struct, length,
data, comm_status, status)
DEVICE_DATA *device_struct; /* INPUT: device data */
ADDR_DATA *address_struct; /* INPUT: Start address for the read */
int length; /* INPUT: number of bytes to read */
char *data; /* OUTPUT: where to put the data */
int *comm_status; /* OUTPUT: Communication status */
/* TOOLKIT_SUCCESS - No
communications problems
during processing */
/* TOOLKIT_FAILURE -
Communications */
/* problem(s) during processing*/
int *status; /* OUTPUT: Function completion status*/
/* TOOLKIT_SUCCESS - Function
completed */
/* model verification
successfully */
/* TOOLKIT_FAILURE - Model did
not VERIFY */
{
int i;
char tx_buf[10];
char rx_buf[14];
length = 14;

tx_buf[0] = MSG_BEGIN;
tx_buf[1] = BLK_READ;
tx_buf[2] = START_ADDR_MSB;
tx_buf[3] = START_ADDR_LSB;
tx_buf[4] = DATA_SIZE_MSB;
tx_buf[5] = DATA_SIZE_LSB;
tx_buf[6] = TIMEOUT_MSB;
tx_buf[7] = TIMEOUT_LSB;
tx_buf[8] = MSG_TERM;
tx_buf[9] = MSG_TERM;

for (i = 0; i < 10; i++)
{
WriteByte(tx_buf);
}

for (i = 0; i < 14; i++)
{
rx_buf = ReadByte();
}

switch (address_struct->domain_index)
{
case 0:
memcpy (data, &rx_buf[0], 10);
break;

caes 1 ... 9 (ignored)

default:
*status = TOOLKIT_FAILURE;
return;
}

*comm_status = TOOLKIT_SUCCESS;
*status = TOOLKIT_SUCCESS;
return;
}

void WriteByte(char data)
{
DWORD iBytesWritten;

iBytesWritten = 0;
WriteFile(port_handle, &data, 1, &iBytesWritten, NULL);
}

char ReadByte(void)
{
char data;
DWORD dwBytesTransferred = 0;

ReadFile(port_handle, &data, 1, &dwBytesTransferred, 0);
if (dwBytesTransferred == 1)
{
return data;
}
}
 
I know that if you put an array point into a point control panel, you only see the first element of the array. To see the additional elements, you need to double click on the point name in the point control panel.

I don't know whether this also applies to text points, but its worth checking into. If Cimplicity treats text points as integer arrays with two characters per integer, that might explain what you're seeing.

Note that these observations are based on experience with version 4.xx Cimplicity. They're currently at version 6.xx, so its possible that none of this is valid for your application.
 
To seppoalanen,

rx_buf[2] = 0x00, it is a 00H value which i read from RFID. the data format 2 bytes which are (MSB)00H (LSB)(data)H. do u meant 00H represents end of string, so my point will display up to rx_buf[2] only?



To Steve,
im using version 5.0. the point is set as class TEXT and data type STRING_80. it's same (2 characters) even i double clicked on point name in point control panel.

->If Cimplicity treats text points as integer arrays with two
characters per integer, that might explain what you're seeing

if the cimplicity really does so... then how do i see the actual value? because i need to display the value on the screen.



thank you very much.

regards,
glen
 
Writing problem now...

the writing data code in usrtm_wrdt.c is:

memcpy (DOMAIN0, data, length);

which can say the reverse of read data. but, i found declaration problem when im building the executable. it said "Undeclared identifier" for DOMAIN0. how do i write data into DOMAIN0? do i need to declare DOMAIN0? or use address_struct(not sure)?

note:
seppoalanen, u're right. 0x00 represents end of string, so i have to filter out all 0x00. it works perfectly now.

thank you very much.

regards,
glen
 
Re: Writing problem now...

glenglen said:
the writing data code in usrtm_wrdt.c is:

memcpy (DOMAIN0, data, length);

which can say the reverse of read data. but, i found declaration problem when im building the executable. it said "Undeclared identifier" for DOMAIN0. how do i write data into DOMAIN0? do i need to declare DOMAIN0?

I think you need. Is it some windows system variable ? If, then you need find it's header/class or equal. Maybe I'm wrong...
 
i've solved my problem already, the correct code should be:

memcpy (&data[address_struct->domain_offset], data_to_send, length);

thanks you.

regards,
glen
 

Similar Topics

Hi, I am developing project in Cimplicity 9.0 and I want to communicate it with PLC on S90_TRIPLEX protocol. Also want to communicate with...
Replies
1
Views
2,338
I have a question related to the tag definition of a Cimplicity HMI tag. I have an existing application in which I have csv export of the tag DB...
Replies
1
Views
2,049
Hi Members! Can anybody give an useable link where can I download GE-Fanuc CIMPLICITY HMI v6.0 software? I would like to install this software...
Replies
2
Views
2,957
Hello everyone, I'm learning to program the Cimplicity HMI 8.2 recently. Do you have any suggestions where can I find some helpful manuals or...
Replies
1
Views
8,845
Back to forum!📚 I'm working on a project that requires upgrading Cimplicity HMI from Version 7 to 8.2. Does anyone here knows if the new...
Replies
3
Views
4,217
Back
Top Bottom