Posts
Callback functon - Fixed
- Get link
- X
- Other Apps
I just love people who make the effort and help to teach others new stuff. But with code samples i don't understand why you don't test the code before publishing. I found an interesting example off callback function example but it was not working. Here is the proper stuff:) #include <stdio.h> #include <stdlib.h> typedef struct { int age ; char name [ 10 ] ; char surname [ 10 ] ; } person ; // Simple fuction to be called as callback void callMe ( person * m ) { printf ( "%d %s %s \n \r " , m -> age , m -> name , m -> surname ) ; } int main ( int argc , char * argv [ ] ) { // Declaration of pointer to function with same signiture as callMe void ( * callback ) ( person * ) ; // Create struct and fill with data person s ; s. age = 27 ; //Don't forget how to copy strings in C/C++ ...
Delay .bat script
- Get link
- X
- Other Apps
Windows is a strange thing, especially at startup. Things are just loading and loading:) Sometimes strange things happen if a program in startup folder starts before everything is loaded. There is simple way to delay your program to start with ping command. Save bellow command to file and name give it an arbitrary name with bat extension. For example: run.bat ping -w 1000 -n 10 localhost D:\MyProgram.exe Create link to this file in windows startup folder and your program will start after it pings itself 10 times. Bellow I also copied explanation about ping command. PING is used to test TCP/IP connectivity with another host and gives information about the length of time test data takes to be sent to the host and a reply received. Its most basic use is as follows: C:\ ping IP address or hostname Pinging 160.82.52.11 with 32 bytes of data: Reply from 160.82.52.11: bytes=32 time=10ms TTL=252 Reply from 160.82.52.11: bytes=32 time<10ms TTL=252 Reply from 160.8...
Copy array from round buffer with memcopy()
- Get link
- X
- Other Apps
Since I started to work with embedded systems I had to start thing about pointers... A subject foreign in my previews Java development. Bellow is a small spinet of my code to copy arrays with pointers. Also the use of some Microblaze functions use are shown... void BufferMemoryCopy ( void * dest , GPS_BUFFER * buff , u16 buff_offset , u32 size ) { // Microblaze -- typedef Xuint16 u16; u16 pos = ( buff -> Tail16 + buff_offset ) & GPS_FIFO_MASK ; // Fifo mast is used in roun buffer if ( ( pos + size ) <= GPS_FIFO_SIZE ) { memcpy ( dest , & buff -> Buffer [ pos ] , size ) ; } else { memcpy ( dest , & buff -> Buffer [ pos ] , GPS_FIFO_SIZE - pos ) ; memcpy ( dest + ( GPS_FIFO_SIZE - pos ) , & buff -> Buffer [ 0 ] , size - ( GPS_FIFO_SIZE - pos ) ) ;