CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

Looking for any monitor routines

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jgoss
Guest







Looking for any monitor routines
PostPosted: Thu Jan 23, 2003 5:35 pm     Reply with quote

Hi,
I am about ready to write some RS232 monitor routines to make an easy way of monitoring & controlling my project. I was wondering if anybody out there has already done something like this, so I don't have to totally re-invent the wheel.

I am thinking along the lines of a simple one or two letter command input gets me some function output such as:

? gives me the menu

The menu may look something like:

D = Dump EEPROM
L = Data Log dump
V = Read Voltage
C = Read Current
...

If anyone has done something like this I would sure like to get a copy.

Thanks,
John Goss
___________________________
This message was ported from CCS's old forum
Original Post ID: 10954
Steve H
Guest







What I do.....
PostPosted: Thu Jan 23, 2003 7:35 pm     Reply with quote

John: You can look at a simple command parser that I have used for many projects.

Check out the link below, on that page you can download the source code....

Regards,

Steve H
___________________________
This message was ported from CCS's old forum
Original Post ID: 10955
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

More than you wanted
PostPosted: Fri Jan 24, 2003 9:40 am     Reply with quote

This is what I am using to perform software debugging. I have access to every variable in ram with these two function. The first function sets up the data transfer. The second function moves data. I can process around 10 packets per second at 9600 baud. I'm planning to writeup a project using a pic to aquire 8 analog bytes and 8 bits making a poor mans logic analizer/scope. I plan to release well documented source for the pic and sell the PC interface. I also plan to include source for interupt driven serial packet handeling as well. Making a complete developers toolkit. You may be able to adapt some of this to your purpose.


/***************************************************************************
* MODBUS Function code 66 (custom) Debug Write Table of PIC RAM Addresses *
***************************************************************************/
// Debug Write Table of PIC RAM Addresses
// INPUT: Addresses of the 8 data bytes
// PacketBuff[2] is Hi address byte of 1st data byte
// PacketBuff[3] is Low address byte of 1st data byte
// PacketBuff[4] is Hi address byte of 2nd data byte
// PacketBuff[5] is Low address byte of 2nd data byte
// PacketBuff[6] is Hi address byte of 3rd data byte
// PacketBuff[7] is Low address byte of 3rd data byte
// PacketBuff[8] is Hi address byte of 4th data byte
// PacketBuff[9] is Low address byte of 4th data byte
// PacketBuff[10] is Hi address byte of 5th data byte
// PacketBuff[11] is Low address byte of 5th data byte
// PacketBuff[12] is Hi address byte of 6th data byte
// PacketBuff[13] is Low address byte of 6th data byte
// PacketBuff[14] is Hi address byte of 7th data byte
// PacketBuff[15] is Low address byte of 7th data byte
// PacketBuff[16] is Hi address byte of 8th data byte
// PacketBuff[17] is Low address byte of 8th data byte
//
// Each pair of bytes below pertains to one bit of the 9th data byte.
// The high order address byte uses its low 5 bits for the address and the high 3 bits for the bit number within the byte
// PacketBuff[18] is Hi address byte of 9th data byte bit 0. High 3 bits for bit number
// PacketBuff[19] is Low address byte of 9th data byte
// PacketBuff[20] is Hi address byte of 9th data byte bit 1. High 3 bits for bit number
// PacketBuff[21] is Low address byte of 9th data byte
// PacketBuff[22] is Hi address byte of 9th data byte bit 2. High 3 bits for bit number
// PacketBuff[23] is Low address byte of 9th data byte
// PacketBuff[24] is Hi address byte of 9th data byte bit 3. High 3 bits for bit number
// PacketBuff[25] is Low address byte of 9th data byte
// PacketBuff[26] is Hi address byte of 9th data byte bit 4. High 3 bits for bit number
// PacketBuff[27] is Low address byte of 9th data byte
// PacketBuff[28] is Hi address byte of 9th data byte bit 5. High 3 bits for bit number
// PacketBuff[29] is Low address byte of 9th data byte
// PacketBuff[30] is Hi address byte of 9th data byte bit 6. High 3 bits for bit number
// PacketBuff[31] is Low address byte of 9th data byte
// PacketBuff[32] is Hi address byte of 9th data byte bit 7. High 3 bits for bit number
// PacketBuff[33] is Low address byte of 9th data byte
// OUTPUT: Store the 32 input bytes into RAM to define the location of 9 data bytes, the 9th bite is for 8 separately located bits
// Set PacketBuffSize to 33 (the offset of the last data byte which is unchanged from when input)
void Debug_Load_Addresses(void) // MODBUS Function code 66. Debug Write Table of PIC RAM Addresses
{ memcpy( Lookup_Table, &PacketBuff[2], 32 ); // move the 32 input bytes into RAM to define the location of 9 data bytes
PacketBuffSize = 33; // Index of packets last byte, needed for CRC
debug_66_initialized = 1; // set flag that the Lookup_Table was initialized
}

/***************************************************************************************************************
* MODBUS Function code 67 (custom) Debug Read or Write 9 bytes from/to PIC RAM. Then send result to input device *
***************************************************************************************************************/
// Debug Read & send 9 bytes from PIC RAM or instead write 9 bytes to PIC RAM followed by reading it back and sending it to input device
// INPUT: If PacketBuff[11] is nonzero, the following 9 bytes are input:
// PacketBuff[2] is the 1st data byte (to be writen to PIC RAM)
// PacketBuff[3] is the 2nd data byte (to be writen to PIC RAM)
// PacketBuff[4] is the 3rd data byte (to be writen to PIC RAM)
// PacketBuff[5] is the 4th data byte (to be writen to PIC RAM)
// PacketBuff[6] is the 5th data byte (to be writen to PIC RAM)
// PacketBuff[7] is the 6th data byte (to be writen to PIC RAM)
// PacketBuff[8] is the 7th data byte (to be writen to PIC RAM)
// PacketBuff[9] is the 8th data byte (to be writen to PIC RAM)
// PacketBuff[10] is the 9th data byte (to be writen to PIC RAM as independent bits)
// If PacketBuff[11] is 0, the above bytes are not used
// OUTPUT: The device that sends this command to this PIC chip (CCM) requests either of two commands:
// (1) read 9 bytes from PIC RAM and send this to the calling device.
// (2) write 9 bytes to PIC RAM and then read this back from PIC RAM and send this to the calling device.
// For fucntion (1) above PacketBuff[11] is 0 as input.
// For fucntion (2) above PacketBuff[11] is nonzero as input.
//
// Whichever function is requested, it is done according to the table of PIC RAM Addresses loaded from the last Modbus function 66.
//
// The following packet is sent to the input device:
// PacketBuff[2] is the 1st data byte
// PacketBuff[3] is the 2nd data byte
// PacketBuff[4] is the 3rd data byte
// PacketBuff[5] is the 4th data byte
// PacketBuff[6] is the 5th data byte
// PacketBuff[7] is the 6th data byte
// PacketBuff[8] is the 7th data byte
// PacketBuff[9] is the 8th data byte
// PacketBuff[10] is the 9th data byte, but composed from 8 scattered bits from 8 independent addresses (see function code 66)
// PacketBuffSize is 10, the offset of the last data byte
void Debug_Read_Write(void) // MODBUS Function code 67. Debug Read or Write 9 bytes from/to PIC RAM. Then send result to input device
{ int8 i, k, high;
int16 addr;
int8 const mask_array_set[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
int8 const mask_array_clear[8] = { 0xFE, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xBF, 0x7F };
int8 y, z;

if ( !debug_66_initialized ) // if Lookup_Table is NOT loaded
{ PacketBuff[1] = PacketBuff[1] + 128; // COMMAND NOT SUPPORTED YET
PacketBuff[2] = 0x01; // send trivial packet
PacketBuffSize = 2;
return;
}

if ( PacketBuff[11] ) // if input command is writing and then reading it back out
{ // Write 8 bytes to PIC RAM according to the Table of PIC RAM Addresses loaded from the last Modbus function 66
for ( i = 0, k = 2; k < 10; i += 2, k++ ) // write first 8 bytes
{ addr = make16( Lookup_Table[i], Lookup_Table[i+1] ); // obtain address of next location
*addr = PacketBuff[k]; // insert byte into table
}
// Write 9th byte as 8 bits to PIC RAM according to the Table of PIC RAM Addresses loaded from the last Modbus function 66
y = PacketBuff[10];
for ( i = 16; i < 33; i += 2 ) // write 9th byte as 8 separate bits
{ high = Lookup_Table[i] & 0x01F; // isolate the high order 5 bits of the 13 bit address
addr = make16( high, Lookup_Table[i+1] ); // obtain address of the byte for the next bit
z = Lookup_Table[i]>>5;
if ( bit_test( y, 0 ) ) *addr = *addr | mask_array_set[ z ]; // if input bit is set, set the table bit
else *addr = *addr & mask_array_clear[ z ]; // if bit is clear, clear the table bit
y = y>>1;
}
}
// Logic common to both input fucntions: reading from PIC RAM
// Read 8 bytes from PIC RAM according to the Table of PIC RAM Addresses loaded from the last Modbus function 66
for ( i = 0, k = 2; k < 10; i += 2, k++ ) // read first 8 bytes
{ addr = make16( Lookup_Table[i], Lookup_Table[i+1] ); // obtain address of next location
PacketBuff[k] = *addr; // insert byte into output buffer
}
PacketBuff[10] = 0; // initialize so we only need to set bits (not clear bits)
// Read 9th byte from PIC RAM as 8 bits according to the Table of PIC RAM Addresses loaded from the last Modbus function 66
for ( i = 16, k = 0; k < 8; i += 2, k++ ) // read 9th byte as 8 separate bits
{ high = Lookup_Table[i] & 0x01F; // isolate the high order 5 bits of the 13 bit address
addr = make16( high, Lookup_Table[i+1] ); // obtain address of the byte for the next bit
if ( *addr & mask_array_set[ Lookup_Table[i]>>5 ] ) // if result bit is set
PacketBuff[10] = PacketBuff[10] | mask_array_set[ k ]; // set the output bit
// NOT NEEDED DUE TO INITIALIZATION: else PacketBuff[10] &= mask_array_clear[ k ]; // clear the output bit
}
PacketBuffSize = 10; // Index of packet's last byte, needed for CRC
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 10968
Hans Wedemeyer
Guest







Re: Looking for any monitor routines
PostPosted: Fri Jan 24, 2003 4:11 pm     Reply with quote

Not knowing the details of your project other than
what you have mnentioned here.

Have you looked at or considered MODBUS ?

For simple items like Read Voltage, Read Current, etc. it sounds like MODBUS to me.

More info at

<a href="http://www.modbus.org/default.htm" TARGET="_blank">http://www.modbus.org/default.htm</a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 10979
john Goss
Guest







Re: What I do.....
PostPosted: Fri Jan 24, 2003 5:15 pm     Reply with quote

Thanks guys, this helps


:=John: You can look at a simple command parser that I have used for many projects.
:=
:=Check out the link below, on that page you can download the source code....
:=
:=Regards,
:=
:=Steve H
___________________________
This message was ported from CCS's old forum
Original Post ID: 10983
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group