FORGOT YOUR DETAILS?

CREATE ACCOUNT

Unison Help

  1. Unison Kernel
    1. Pthreads
      1. pthread_create()
      2. pthread_exit()
      3. pthread_self()
      4. pthread_equal()
      5. pthread_join()
      6. pthread_detach()
      7. pthread_setschedparam()
      8. pthread_getschedparam()
      9. pthread_attr_init()
      10. pthread_attr_destroy()
      11. pthread_attr_setstackaddr()
      12. pthread_attr_getstackaddr()
      13. pthread_attr_setstacksize()
      14. pthread_attr_getstacksize()
      15. pthread_attr_setschedparam()
      16. pthread_attr_getschedparam()
      17. pthread_attr_setdetachstate()
      18. pthread_attr_getdetachstate()
      19. pthread_stackinfo()
      20. pthread_setprio()
      21. pthread_getprio()
      22. sched_get_priority_max()
      23. sched_get_priority_min()
      24. sched_yield()
    2. Pthread Cancellation
      1. pthread_cleanup_pop()
      2. pthread_cleanup_push()
      3. pthread_cancel()
      4. pthread_setcanceltype()
      5. pthread_setcancelstate()
      6. pthread_testcancel()
    3. Mutex
      1. pthread_mutex_init()
      2. pthread_mutex_destroy()
      3. pthread_mutex_lock()
      4. pthread_mutex_trylock()
      5. pthread_mutex_unlock()
    4. Semaphores
      1. sem_open()
      2. sem_close()
      3. sem_unlink()
      4. sem_init()
      5. sem_destroy()
      6. sem_wait()
      7. sem_trywait()
      8. sem_timedwait()
      9. sem_post()
      10. sem_getvalue()
    5. Message Queues
      1. mq_open()
      2. mq_close()
      3. mq_unlink()
      4. mq_send()
      5. mq_receive()
      6. mq_notify()
      7. mq_setattr()
      8. mq_getattr()
      9. mq_timedreceive()
      10. mq_timedsend()
    6. Conditional Variables
      1. pthread_cond_init()
      2. pthread_cond_destroy()
      3. pthread_cond_wait()
      4. pthread_cond_timedwait()
      5. pthread_cond_signal()
      6. pthread_cond_broadcast()
      7. pthread_condattr_init()
      8. pthread_condattr_destroy()
    7. Barriers
      1. pthread_barrier_init()
      2. pthread_barrier_destroy()
      3. pthread_barrier_wait()
    8. Timers
      1. timer_create()
      2. timer_delete()
      3. timer_settime()
      4. timer_gettime()
      5. timer_getoverrun()
      6. timer_tick()
      7. nanosleep()
    9. Clocks
      1. time()
      2. uptime()
      3. sleep()
      4. clock_settime()
      5. clock_gettime()
      6. clock_getres()
      7. clock_init()
    10. Memory Allocation
      1. POSIX.1
        1. malloc()
        2. free()
      2. Variable Length (Pools)
        1. pool_create()
        2. pool_destroy()
        3. pool_alloc()
        4. pool_free()
      3. Fixed Length (Partitions)
        1. pt_create()
        2. pt_destroy()
        3. pt_getblock()
        4. pt_freeblock()
    11. Rendezvous
      1. mr_init()
      2. mr_send()
      3. mr_receive()
      4. mr_reply()
      5. mr_sigrecv()
      6. mr_sigpost()
    12. Interrupts
      1. interrupts
      2. i_disable()
      3. i_restore()
    13. Directory Services
      1. dir_register()
      2. dir_deregister()
      3. dir_lookup()
      4. dir_lookup_string()
    14. Miscellaneous
      1. checkIstack()
      2. NanoStart() or DSPexec_Start()
      3. _isrStackFill
      4. Kernel Scaling
      5. kfatal()
      6. kalloc()
      7. kfree()
      8. mpu or mmu
      9. pthreadStackFill
      10. thread_numb()
      11. thread_utilization_start()
      12. thread_utilization_stop()
      13. xprintf()
      14. xputs()
      15. xputchar()
  2. Unison I/O Library
    1. accept()
    2. bind()
    3. chmod()
    4. close()
    5. connect()
    6. creat()
    7. fstat()
    8. getpeername()
    9. getsockname()
    10. getsockopt()
    11. ioctl()
    12. link()
    13. listen()
    14. lseek()
    15. mkdir()
    16. mkfs()
    17. mount()
    18. open()
    19. read()
    20. recv()
    21. recvfrom()
    22. rename()
    23. renameat()
    24. rmdir()
    25. select()
    26. send()
    27. sendto()
    28. setsockopt()
    29. shutdown()
    30. socket()
    31. stat()
    32. sync()
    33. umount()
    34. unlink()
    35. write()
  3. Unison STDIO Library
    1. STDIO Library Calls
      1. clearerr()
      2. dprintf()
      3. fclose()
      4. fdopen()
      5. feof()
      6. ferror()
      7. fileno()
      8. fflush()
      9. fgetc()
      10. fgetpos()
      11. fgets()
      12. fopen()
      13. fprintf()
      14. fputc()
      15. fputs()
      16. fread()
      17. freopen()
      18. fscanf()
      19. fseek()
      20. fseeko()
      21. fsetpos()
      22. ftell()
      23. ftello()
      24. fwrite()
      25. getc()
      26. getc_unlocked()
      27. getchar()
      28. getchar_unlocked()
      29. getdelim()
      30. getline()
      31. gets()
      32. get_stderr_ptr()
      33. get_stdin_ptr()
      34. get_stdout_ptr()
      35. noperprintf()
      36. perprintf()
      37. perror()
      38. posix_compat()
      39. printf()
      40. putc()
      41. putc_unlocked()
      42. putchar()
      43. putchar_unlocked()
      44. puts()
      45. remove()
      46. rewind()
      47. scanf()
      48. setbuf()
      49. setvbuf()
      50. snprintf()
      51. sprintf()
      52. sscanf()
      53. stderr_init()
      54. stderr_close()
      55. stdin_init()
      56. stdin_close()
      57. stdout_init()
      58. stdout_close()
      59. vdprintf()
      60. vscanf()
      61. vsscanf()
      62. vfscanf()
      63. vprintf()
      64. vsnprintf()
      65. vsprintf()
      66. vfprintf()
      67. ungetc()
    2. Do-nothing Stubs
      1. ctermid()
      2. flockfile()
      3. fmemopen()
      4. ftrylockfile()
      5. open_memstream()
      6. pclose()
      7. popen()
      8. tempnam()
      9. tmpfile()
      10. tmpnam()
  4. Unison LIBC Library
    1. LIBC Library Calls
      1. assert()
      2. realloc()
      3. strcasecmp()
      4. strdup()
      5. strncasecmp()
      6. strftime()
    2. Do-nothing Stubs
      1. abort()
      2. execve()
      3. exit()
      4. _Exit()
      5. fork()
      6. getpid()
      7. isatty()
      8. kill()
      9. sbrk()
      10. times()
      11. wait()
    3. Do-nothing Wide-character Stubs
      1. <wchar.h>
      2. <wctype.h>
  5. Unison I/O Servers
    1. File Servers
      1. Multimedia File Server - fsys
      2. FAT File System - fatfs
      3. NAND File Server - nandfsys
      4. NOR File Server - norfsys
      5. Network File Server - nfs
  6. Graphics, Camera, Video, Audio
    1. Vendor Graphics
    2. Prism++ Graphics
    3. ADPCM Services - adpcmd
    4. Camera
  7. Network Protocols
    1. TCP and UDP Server - tcpd
      1. IPv4 only server
      2. IPv4/IPv6 server
    2. DHCP Client Service - dhcp client
    3. DHCP Server - dhcpd
    4. Telnet Server - telnetd
    5. Tiny FTP Server - tftpd
    6. Point to Point - pppd
    7. Network Translation - NAT with PAT
    8. Firewall
      1. Packet filter: pf
      2. Packet filter control: pfctl
      3. Fitler rules: pf.filtering
      4. Translation rules: pf.nat
    9. Tiny HTTP Server - thttpd
    10. Tiny HTTP Server with TLS
    11. POP3 Server
    12. Simple Mail Transfer Protocol Services (SMTP)
    13. Bootp Protocol
    14. File Transfer Protocol Server (FTP)
    15. File Transfer Client Services
    16. RPC / XDR
    17. DNS Client
    18. HTTP/HTTPS Client
    19. REST Client
    20. AutoIP Service - autoip client
    21. mDNS server - mdnsd
    22. SNTP Client
    23. SNMP Agent - Snmpd server
    24. SSL/TLS library
    25. SSH server
    26. IP security
      1. IPsec description
      2. IPsec administration: ipsecadm
      3. Virtual Private Network: VPN
    27. Power Control
      1. Motor and Motion Control Servers
      2. PWM, Encoders
    28. Serial I/O
      1. Asynchronous Serial I/O Server - ttyserver
      2. CAN Server - cand
      3. I2C Server - i2cd
      4. I2S Server - i2sd
    29. System Services
      1. Power Management Servers
      2. Login Service - login_services
      3. XML
      4. POSIX Shell and Login Service - posh
    30. Universal Serial Bus (USB)
      1. USB Server
      2. USB Device Server
      3. USB Embedded Host Server
    31. Wireless
      1. Wireless Servers and Drivers
      2. 802.15.4 Radio Servers
      3. TCP/v6 with 6loWPAN
      4. ZigBee
      5. BlueTooth Server
      6. 802.11 Wi-Fi
      7. GPRS, UHF and GPS Radio Servers
    32. Remedy Tools for Unison
      1. Remedy Data Logging and Event Display Tools
      2. Remedy Diagnostics
      3. Remedy Flash Downloader/Bootloader
      4. Remedy Power On Self Test - POST
      5. Remedy OS Object Viewer
      6. Remedy Remote Control Tools

7.32.1.Remedy Data Logging and Event Display Tools #

OVERVIEW

The Remedy Data Logging and Event Display Tools consist of two components:
Remedy Data Logger: target side logging component.
Remedy Event and Remote Control Viewer: host side display component.

The Remedy Event and Remote Control Viewer is a host IDE specific tool, therefore it were described in separate file: see directory installdir/manuals.

The Remedy Data Logger is an IDE independent target component. Its operation is described below.


NAME

Data Logger – dlog

SYNOPSIS

#include <dlog.h>

pthread_create(&dlogTid, &dlogattr, (void *)dlog, (void *)&dlog_init);
THREAD dlog(struct dlog_settings *dlog_init);
User events functions:
int dlog_thread_mask(pthread_t id, uint_32 mask);
int dlog_interrupt_mask(int vector, uint_32 mask);
void dlog_set_thread_name(pthread_t id, char *name);
void dlog_set_interrupt_name(int vector, char *name);
void dlog_data(uint_32 d1, uint_32 d2, uint_32 d3, uint_32 d4, uint_32 d5, uint_32 d6);
void dlog_str(char *str);
void dlog_raw(uchar *raw, int num);
Triggers control functions
int dlog_SetTrigVal(uint_8 TrigNum, uint_32 lt_val, uint_32 *lt_ptr, uint_32 eq_val, uint_32 *eq_ptr, uint_32 gt_val, uint_32 *gt_ptr, uint_8 valMask);
int dlog_SetTrigUsr(int(*func)(void));
int dlog_SetSeqMasks(uint_8 SeqMask1, uint_8 SeqMask2, uint_8 SeqMask3, uint_8 SeqMask4, uint_8 TrigBufLoc);
Dlog work control functions
int dlog_SetLogMode(uint_8 Mode);
int dlog_ForceSendLog(void);

DESCRIPTION

The dlog server provides system events logging. Dlog collects and analyses events from all threads, servers and interrupts.

User can choose, what types of events will be logged. It is possible to set the global mask of events for all streams or individually for every stream, server or interrupt.

Dlog server events masks and their functions:

Kernel log events mask:

    • DLOG_MASK_MALLOC

 

    • – malloc(), free()

 

    • DLOG_MASK_POOL

 

    • – pool_create(), pool_destroy(), pool_alloc(), pool_free()

 

    • DLOG_MASK_PT

 

    • – pt_create(), pt_destroy(), pt_getblock(), pt_freeblock()

 

    • DLOG_MASK_MQ

 

    • – mq_open(), mq_close(), mq_unlink(), mq_receive() / mq_timedreceive(), mq_send() / mq_timedsend()

 

    • DLOG_MASK_MR

 

    • – mr_init(), mr_receive(), mr_reply(), mr_send(), mr_sigpost(), mr_sigrecv()

 

    • DLOG_MASK_BARRIER

 

    • – pthread_barrier_init(), pthread_barrier_destroy(), pthread_barrier_wait()

 

    • DLOG_MASK_CANCEL

 

    • – pthread_cancel(), pthread_testcancel(), pthread_cleanup_push(), pthread_cleanup_pop(), pthread_setcancelstate(), pthread_setcanceltype()

 

    • DLOG_MASK_COND

 

    • – pthread_cond_init(), pthread_cond_destroy(), pthread_cond_broadcast(), pthread_cond_signal(), pthread_cond_wait()

 

    • DLOG_MASK_PTHREAD_STATE

 

    • – pthread_create(), pthread_exit(), pthread_join(), sched_yield()

 

    • DLOG_MASK_MUTEX

 

    • – pthread_mutex_init(), pthread_mutex_destroy(), pthread_mutex_lock(), pthread_mutex_trylock(), pthread_mutex_unlock()

 

    • DLOG_MASK_SEM

 

    • – sem_open(), sem_init(), sem_close(), sem_destroy(), sem_unlink(), sem_post(), sem_wait(), sem_timedwait(), sem_trywait()

 

    • DLOG_MASK_SLEEP

 

    • – nanosleep()

 

    • DLOG_MASK_TIMER

 

    • – timer_create(), timer_delete(), timer_gettime(), timer_settime()

 

    • DLOG_MASK_CLOCK

 

    • – clock_init(), clock_settime(), clock_getres(), clock_gettime()

 

    • DLOG_MASK_KERNEL_ALL

 

    • – all above kernel functions

User log events mask:

    • DLOG_MASK_USER

 

    • – dlog_data(), dlog_str(), dlog_raw()

Iolib log events mask:

    • DLOG_MASK_SOCKET

 

    • – open(), close(), socket(), bind(), connect(), listen(), accept(), select(), recv(), recvfrom(), send(), sendto(), shutdown(), getpeername(), getsockname(), getsockopt(), setsockopt()

 

    • DLOG_MASK_FS

 

    • – open(), close(), mkfs(), mount(), nfsmount(), umount(), create(), link(), unlink(), sync(), fsync(), fstat(), stat(), chmod(), lseek(), mkdir(), rmdir(), getdirentries()

 

    • DLOG_MASK_RDWR

 

    • – open(), close(), read(), write(), ioctl()

 

    • DLOG_MASK_IOLIB_ALL

 

    • – all above iolib functions

Others mask:

    • DLOG_MASK_INTERRUPT

 

    • – log interrupts events

 

    • DLOG_MASK_ALL

 

    • – global mask for all events

 

The dlog server logs events in compliance with specified threads, interrupts and global masks and sends these events to remote host and/or writes its to a file.


Dlog server initialization

The dlog server initiatization structure can be found in the file <dlog.h>:

/*
 * dlog initialization structure
 */
struct dlog_settings
{
    int log_buff_size;          // events buffer - events count
    uint_32 polling_interval;   // events polling interval - ms
    int flush_edge;             // minimum flush events count

    uint_32 event_mask;         // logging events - global mask
    char threads_flow_log;      // log or not threads flow

    char *log_file;             // write log in file
    uint_32 file_len;           // maximum log file length

    char *remote_ip;            // send log to remote host
    u_short remote_port;
};

At initialization dlog allocates memory for log_buff_size events. All threads and interrupts write their events in this shared buffer. The Dlog server scans the buffer with a polling_interval period. If number of events in the buffer is equal to or greater than flush_edge – dlog sends the log to the remote host or/and writes in file.

Dlog has a global events mask event_mask. This mask applies with all threads and interrupts masks. The kernel has some internal unmaskable events for tracking threads context switch trace. These events are necessary for the correct interpretation of behavior of the system. These events can be removed from log if threads_flow_log is set to zero.

If a log_file was specified, dlog will write events in this file. If the file_len is not equal to zero, dlog will write the log in separate files with sizes not more, than file_len bytes. Log files will be named as “user file name” + “file number”.

If remote_ip was specified, dlog will send events to this IP-address at port remote_port by UDP protocol.


User events functions

Dlog has different user functions for logging event management.

int dlog_thread_mask(pthread_t id, uint_32 mask);
Set event mask mask for thread id.

int dlog_interrupt_mask(int vector, uint_32 mask);
Set event mask mask for interrupt vector.

void dlog_set_thread_name(pthread_t id, char *name);
Set name *name for thread id. Maximum name length can be 32 bytes.

void dlog_set_interrupt_name(int vector, char *name);
Set name *name for interrupt vector. Maximum name length can be 32 bytes.

void dlog_data(uint_32 d1, uint_32 d2, uint_32 d3, uint_32 d4, uint_32 d5, uint_32 d6);
Generate user log dats event. User can logged up to sixt 32-bits unsigned values.

void dlog_str(char *str);
Generate user log string event. Maximum string length can be 24 bytes.

void dlog_raw(uchar *raw, int num);
Generate user log raw buffer event. Maximum buffer length can be 24 bytes.


Triggers control functions

Dlog has an additional operational mode – send log only if some conditions are met. This behavior is realized with help of a triggers mechanizm which is used for setting up the specific condition for logging. There are 3 “value” triggers and 1 “user” trigger. The system analyzes all enabled triggers and if a trigger or triggers sequence was latched, dlog sends or writes all logged events from the buffer.

int dlog_SetTrigVal(uint_8 TrigNum, uint_32 lt_val, uint_32 *lt_ptr, uint_32 eq_val, uint_32 *eq_ptr, uint_32 gt_val, uint_32 *gt_ptr, uint_8 valMask);
Setup “value trigger” number TrigNum. User can set:
– value lt_val and address *lt_ptr: trigger will be latched if value at address *lt_ptr will be less than lt_val;
– value eq_val and address *eq_ptr: trigger will be latched if value at address *eq_ptr will be equal than eq_val;
– value gt_val and address *gt_ptr: trigger will be latched if value at address *gt_ptr will be greate than lt_val.
With the help of valMask the user can choose activity masks and its logical operation:
– TRIG_LT_VAL: scan “less than” value;
– TRIG_EQ_VAL: scan “equal to” value;
– TRIG_GT_VAL: scan “greater than” value;
– VALS_AND: trigger will be latched if all selected items are true values. By default the item is latched if one of the values is true.

int dlog_SetTrigUsr(int(*func)(void));
Setup “user trigger” function *func. Trigger will be latched, if user function return 1. If the user condition is not true, the function must returns 0.

int dlog_SetSeqMasks(uint_8 SeqMask1, uint_8 SeqMask2, uint_8 SeqMask3, uint_8 SeqMask4, uint_8 TrigBufLoc);
Dlog has triggers sequence masks and buffer position control. Dlog checks triggers from SeqMask1, then from SeqMask2, then from SeqMask3 and from SeqMask4. Masks bits:
– TRIG_VAL3: wait “value trigger” #3;
– TRIG_VAL2: wait “value trigger” #2;
– TRIG_VAL1: wait “value trigger” #1;
– TRIG_USER: wait “user trigger”;
– TRIGS_AND: log will be send/write if all selected triggers are latched. By default this is true if one of the triggers is latched.
Parameter TrigBufLoc setup latched trigger location inside logged buffer:
– TRIG_BUFF_BEFORE: send all events, which were written to the buffer before the trigger;
– TRIG_BUFF_AFTER: send all events, which were writen to the buffer after the trigger;
– TRIG_BUFF_MIDDLE: send half the buffer events which were written to buffer before trigger, and half buffer events which were written to buffer after trigger.


Dlog work control functions

int dlog_SetLogMode(uint_8 Mode);
Set dlog work mode. Parameter Mode can be:
– LOG_OFF: not log events;
– LOG_NOSEND: log events, but not send/write its;
– LOG_AUTOLOG: log events and always send/write its;
– LOG_TRIG_SINGLE: log events and wait trigger. After trigger occurs – send log buffer and switch to LOG_NOSEND mode;
– LOG_TRIG_CONTINUE: log events and wait trigger. After trigger occurs – send log buffer and continue.

int dlog_ForceSendLog(void);
If dlog works in LOG_NOSEND mode, user can send/write current buffer with logged events.

RETURN VALUES

All dlog functions return 0 on success and -1 on all other conditions.

ERRORS

All errors are handled by the return values.

EXAMPLE

This partial example shows the creation and registration of the dlog server.

#include <dlog.h>

/*
 * dlog variables and start routine
 */
struct dlog_settings dlog_init;

void dlog_start(void)
{
	pthread_t dlogTid;
	pthread_attr_t dlogattr;
	struct sched_param dlogPriority;


	// Fill parameters
	dlog_init.log_buff_size = 50;
	dlog_init.polling_interval = 30;
	dlog_init.flush_edge = 10;
	dlog_init.event_mask = DLOG_MASK_ALL;
	dlog_init.threads_flow_log = 1;
	dlog_init.log_file = "/dev/rd/tftpboot/logfile";
	dlog_init.file_len = 2048;
	dlog_init.remote_ip = "192.168.16.2";
	dlog_init.remote_port = 15000;


	pthread_attr_init(&dlogattr);
	pthread_attr_setstacksize(&dlogattr, 1400);
	dlogPriority.sched_priority = 6;
	pthread_attr_setschedparam(&dlogattr, &dlogPriority);

	pthread_create(&dlogTid, &dlogattr, (void *)dlog, (void *)&dlog_init);
	pthread_attr_destroy(&dlogattr);
}

After creation, you must set logged interrupts and threads

	. . .

	dlog_start();
	sleep(1);

	// Main
	dlog_set_thread_name(pthread_self(), "MainThread");
	dlog_thread_mask(pthread_self(), DLOG_MASK_ALL);

	// System timer
	dlog_set_interrupt_name(TIMER_INTERRUPT_ID, "SysTimer");
	dlog_interrupt_mask(TIMER_INTERRUPT_ID, DLOG_MASK_ALL);

	// Ethernet
	dlog_set_interrupt_name(ETH_INTERRUPT_ID, "EthernetInt");
	dlog_set_thread_name(tcp_tid, "tcpd");
	dlog_interrupt_mask(ETH_INTERRUPT_ID, DLOG_MASK_ALL);
	dlog_thread_mask(tcp_tid, DLOG_MASK_ALL);

	// fsys
	dlog_set_thread_name(fsys_tid, "fsys");
	dlog_thread_mask(fsys_tid, DLOG_MASK_ALL);

	// tftpd
	dlog_set_thread_name(tftp_tid, "tftpd");

	. . .

If need them, you can setup triggers

	. . .

	// set trigger value (trig at =5 or >15)
	dlog_SetTrigVal(1,                  // trigger value #1
            0, NULL,                    // lt_val
            5, &var,                    // eq_val
            15, &var,                   // gt_val
            TRIG_EQ_VAL | TRIG_GT_VAL); // trigger at eq_val or gt_val

	// set user trigger
	dlog_SetTrigUsr(UserTrig);

	// wait trigger value #1 or user trigger
	dlog_SetSeqMasks(TRIG_VAL1 | TRIG_USER, 0, 0, 0, TRIG_BUFF_MIDDLE);

	// do not stop logging after trigger
	dlog_SetLogMode(LOG_TRIG_SINGLE);

	. . .

NOTES

There is a demo available for the Unison and DSPnano dlog server which is found in installdir/demos.

SEE ALSO

Remote Control Tools

Suggest Edit

CONTACT US

TO GET YOUR PROJECT STARTED

TOP