{"id":2351,"date":"2021-11-12T17:40:51","date_gmt":"2021-11-12T17:40:51","guid":{"rendered":"https:\/\/yazilimperver.com\/?p=2351"},"modified":"2021-11-12T17:40:51","modified_gmt":"2021-11-12T17:40:51","slug":"haftalik-c-42-vxworks-icin-saat-guncelleme","status":"publish","type":"post","link":"https:\/\/yazilimperver.com\/index.php\/2021\/11\/12\/haftalik-c-42-vxworks-icin-saat-guncelleme\/","title":{"rendered":"Haftal\u0131k C++ 42 \u2013 VxWorks i\u00e7in saat g\u00fcncelleme"},"content":{"rendered":"<p>Merhaba sevgili yaz\u0131l\u0131mperver dostlar\u0131m, bu yaz\u0131mda sizler i\u00e7in faydal\u0131 olaca\u011f\u0131n\u0131 d\u00fc\u015f\u00fcnd\u00fc\u011f\u00fcm (\u00f6zellikle VxWorks i\u00e7in yaz\u0131l\u0131m geli\u015ftirenler) bir kod payla\u015f\u0131p, yeni repolar\u0131n duyurusunu yapmak istiyorum.<\/p>\n<p>\u00d6ncelikle, yeni repo&#8217;lar\u0131n duyurusunu yapay\u0131m. Daha \u00f6nce sizler ile, \u00e7e\u015fitli vesileler ile haftal\u0131k veya modern c++ yaz\u0131lar\u0131yla payla\u015ft\u0131\u011f\u0131m kodlar\u0131 (bu dahil) ve kulland\u0131\u011f\u0131m di\u011fer ara\u00e7lar\u0131 listeledi\u011fim repolara a\u015fa\u011f\u0131daki adreslerden ula\u015fabilirsiniz:<\/p>\n<p><span style=\"color: #008000;\"><strong><a style=\"color: #008000;\" href=\"https:\/\/github.com\/yazilimperver\/CodeSnippets\">https:\/\/github.com\/yazilimperver\/CodeSnippets<\/a><\/strong><\/span><\/p>\n<p><span style=\"color: #008000;\"><strong><a style=\"color: #008000;\" href=\"https:\/\/github.com\/yazilimperver\/ToolRepository\">https:\/\/github.com\/yazilimperver\/ToolRepository<\/a><\/strong><\/span><\/p>\n<p>Bundan sonra payla\u015faca\u011f\u0131m yaz\u0131larda olacak \u00f6nemli kod par\u00e7alar\u0131n\u0131 da bu repositoryler i\u00e7erisinde tutuyor olaca\u011f\u0131m.<\/p>\n<p>\u015eimdi gelelim yaz\u0131m\u0131n ba\u015f\u0131nda bahsetti\u011fim kod par\u00e7as\u0131na.<\/p>\n<p>G\u00f6m\u00fcl\u00fc yaz\u0131l\u0131m geli\u015ftiricisi olarak, kimi zaman RTC&#8217;leri veya di\u011fer saatleri g\u00fcncelleme ihtiyac\u0131 olabiliyor. RTC&#8217;leri genelde bir kere g\u00fcncelledikten sonra kullanabilirsiniz fakat zaman\/tarih bilgisini CMOS&#8217;tan da alabilirsiniz. \u0130\u015fte bu ama\u00e7la <a href=\"https:\/\/github.com\/yazilimperver\/CodeSnippets\/blob\/main\/VxWorks\/SetTimeFromCMOS.cpp\"><span style=\"color: #008000;\"><strong>a\u015fa\u011f\u0131daki kodu<\/strong><\/span><\/a> kullanabilirsiniz:<\/p>\n<pre class=\"lang:c++ decode:true \">\/**\r\n * @file    SetTimeFromCMOS.cpp\r\n * @author  Yaz\u0131l\u0131mperver\r\n * @brief   VxWorks icin CMOS'dan verileri okuyup tarihi ve saati ayarlamak icin kullanilabilecek kod\r\n * @version 0.1\r\n * @date    2021-11-10 \r\n *\/\r\n\r\n#include \"vxWorks.h\"\r\n#include \"time.h\"\r\n#include \"stdio.h\"\r\n#include \"memLib.h\"\r\n#include \"sysLib.h\"\r\n\r\nSTATUS SetTimeFromCMOS (void)\r\n{\r\n    int i;\r\n    time_t     time1;\r\n    struct tm* time2;\r\n\r\n    unsigned int month_array[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};\r\n    unsigned int current_second_bcd;\r\n    unsigned int current_minute_bcd;\r\n    unsigned int current_hour_bcd;\r\n    unsigned int current_day_of_week_bcd;\r\n    unsigned int current_date_bcd;\r\n    unsigned int current_month_bcd;\r\n    unsigned int current_year_bcd;\r\n    unsigned int current_century_bcd;\r\n    unsigned int second;\r\n    unsigned int minute;\r\n    unsigned int hour;\r\n    unsigned int day;\r\n    unsigned int date;\r\n    unsigned int month;\r\n    unsigned int year;\r\n    unsigned int yday;\r\n    unsigned int century;\r\n    struct timespec timespecToUpdate;\r\n\r\n    \/\/ Ilklendirilmemis zaman bilgisini basalim = THU JAN 01 00:00:01 1970\r\n    time1 = time (0);\r\n    time2 = localtime (&amp;time1);\r\n\r\n    printf (\"Current vxWorks Time = %s\", asctime (time2));\r\n\r\n    \/\/ CMOS RAM'den ger\u00e7ek zamanl\u0131 saat b\u0131lg\u0131s\u0131n\u0131 okuyal\u0131m\r\n    \/\/ Bu veriler 0x70 ve 0x71 adreslerinden okunacak\r\n    \/\/ Detaylar i\u00e7in https:\/\/wiki.osdev.org\/CMOS, http:\/\/ics.p.lodz.pl\/~mceg\/telekom\/RTC%20-%20Ports.pdf\r\n    sysOutByte (0x70, 0x0);\r\n    current_second_bcd = sysInByte (0x71);\r\n    sysOutByte (0x70, 0x2);\r\n    current_minute_bcd = sysInByte (0x71);\r\n    sysOutByte (0x70, 0x4);\r\n    current_hour_bcd = sysInByte (0x71);\r\n    sysOutByte (0x70, 0x6);\r\n    current_day_of_week_bcd = sysInByte (0x71);\r\n    sysOutByte (0x70, 0x7);\r\n    current_date_bcd = sysInByte (0x71);\r\n    sysOutByte (0x70, 0x8);\r\n    current_month_bcd = sysInByte (0x71);\r\n    sysOutByte (0x70, 0x9);\r\n    current_year_bcd = sysInByte (0x71);\r\n    sysOutByte (0x70, 0x32);\r\n    current_century_bcd = sysInByte (0x71);\r\n\r\n    \/\/ Ger\u00e7ek zamanl\u0131 BCD saat verisini basal\u0131m\r\n    printf (\"Second = %02X\\nMinute = %02X\\nHour = %02X\\nDay = %02X \\nDate = %02X\\n\", current_second_bcd, current_minute_bcd, current_hour_bcd, \r\n            current_day_of_week_bcd, current_date_bcd);\r\n    printf (\"Month = %02X \\nYear = %02X \\nCentury = %02X\", current_month_bcd,\r\n            current_year_bcd, current_century_bcd);\r\n    \r\n    \/\/ BCD saat verilerini VxWorks'e aktarmak i\u00e7in gerekli donusumleri yapalim\r\n    \/\/ Detaylar i\u00e7in \/WIND_BASE\/target\/h\/time.h\r\n    second = ((current_second_bcd &amp; 0xF0) &gt;&gt; 4) * 10;\r\n    second = second + (current_second_bcd &amp; 0x0F);\r\n\r\n    minute = ((current_minute_bcd &amp; 0xF0) &gt;&gt; 4) * 10;\r\n    minute = minute + (current_minute_bcd &amp; 0x0F);\r\n\r\n    hour = ((current_hour_bcd &amp; 0xF0) &gt;&gt; 4) * 10;\r\n    hour = hour + (current_hour_bcd &amp; 0x0F);\r\n\r\n    day = ((current_day_of_week_bcd &amp; 0xF0) &gt;&gt; 4) * 10;\r\n    day = day + (current_day_of_week_bcd &amp; 0x0F);\r\n\r\n    date = ((current_date_bcd &amp; 0xF0) &gt;&gt; 4) * 10;\r\n    date = date + (current_date_bcd &amp; 0x0F);\r\n\r\n    month = ((current_month_bcd &amp; 0xF0) &gt;&gt; 4) * 10;\r\n    month = month + (current_month_bcd &amp; 0x0F);\r\n\r\n    year = ((current_year_bcd &amp; 0xF0) &gt;&gt; 4) * 10;\r\n    year = year + (current_year_bcd &amp; 0x0F);\r\n\r\n    century = ((current_century_bcd &amp; 0xF0) &gt;&gt; 4) * 10;\r\n    century = century + (current_century_bcd &amp; 0x0F);\r\n    century = century * 100;\r\n\r\n    year = century + year;\r\n    year = year - 1900;\r\n\r\n    for (i = 0; i &lt; month; i++)\r\n        yday = yday + month_array[i];\r\n    yday = yday + date;\r\n\r\n    \/\/ D\u00f6n\u00fc\u015ft\u00fcr\u00fclen verileri basal\u0131m\r\n    printf (\"Converted: Second = %d minute = %d hour = %d \",\r\n        second, minute, hour);\r\n    printf (\"Converted: Date = %d month = %d year = %d day = %d yday = %d\", date, month, year, day, yday);\r\n    \r\n    \/\/ tm veri yap\u0131s\u0131n\u0131 d\u00f6n\u00fc\u015ft\u00fcr\u00fclen veriler ile doldural\u0131m\r\n    time2-&gt;tm_sec = second;\r\n    time2-&gt;tm_min = minute;\r\n    time2-&gt;tm_hour = hour;\r\n    time2-&gt;tm_mday = date;\r\n    \r\n    \/\/ Ay verileri 0-11 aral\u0131\u011f\u0131\r\n    time2-&gt;tm_mon = month-1;  \r\n    time2-&gt;tm_year = year;\r\n    time2-&gt;tm_wday = day;\r\n    time2-&gt;tm_yday = yday;\r\n    time2-&gt;tm_isdst = 1;     \r\n\r\n    \/\/ \u0130lgili veri yap\u0131s\u0131n\u0131 saniyeye \u00e7evirelim\r\n    time1 = mktime (time2);\r\n\r\n    \/\/ VxWorks zaman\u0131n\u0131 yeni zaman ile g\u00fcncelleyelim\r\n    timespecToUpdate.tv_sec = time1;\r\n    timespecToUpdate.tv_nsec = 0;\r\n\r\n    \/\/ \u0130lgili ger\u00e7ek zamanl\u0131 saati g\u00fcncelleyelim\r\n    clock_settime(CLOCK_REALTIME, &amp;timespecToUpdate);\r\n\r\n    \/\/ G\u00fcncellenen zaman\u0131 tekrar okuyal\u0131m ve g\u00fcncellendi\u011fini kontrol edelim\r\n    time1 = time(0);\r\n    time2 = localtime(&amp;time1);\r\n\r\n    printf(\"New vxWorks Time = %s\", asctime(time2));\r\n\r\n    return OK;\r\n}\r\n\r\nint main()\r\n{\r\n    SetTimeFromCMOS();\r\n    return 0;\r\n}<\/pre>\n<p>Bir sonraki haftal\u0131k kod par\u00e7as\u0131nda g\u00f6r\u00fc\u015fmek \u00fczere, kendinize iyi bak\u0131n.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Merhaba sevgili yaz\u0131l\u0131mperver dostlar\u0131m, bu yaz\u0131mda sizler i\u00e7in faydal\u0131 olaca\u011f\u0131n\u0131 d\u00fc\u015f\u00fcnd\u00fc\u011f\u00fcm (\u00f6zellikle VxWorks i\u00e7in yaz\u0131l\u0131m geli\u015ftirenler) bir kod payla\u015f\u0131p, yeni repolar\u0131n duyurusunu yapmak istiyorum. \u00d6ncelikle, yeni repo&#8217;lar\u0131n duyurusunu yapay\u0131m. Daha \u00f6nce sizler ile, \u00e7e\u015fitli vesileler ile haftal\u0131k veya modern c++ yaz\u0131lar\u0131yla payla\u015ft\u0131\u011f\u0131m kodlar\u0131 (bu dahil) ve kulland\u0131\u011f\u0131m di\u011fer ara\u00e7lar\u0131 listeledi\u011fim repolara a\u015fa\u011f\u0131daki adreslerden ula\u015fabilirsiniz: https:\/\/github.com\/yazilimperver\/CodeSnippets&#8230; <a class=\"more-link\" href=\"https:\/\/yazilimperver.com\/index.php\/2021\/11\/12\/haftalik-c-42-vxworks-icin-saat-guncelleme\/\">Continue reading <span class=\"meta-nav\">&#8594;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","_seopress_robots_follow":"","_seopress_robots_imageindex":"","_seopress_robots_snippet":"","_seopress_robots_primary_cat":"10","_seopress_robots_breadcrumbs":"","_seopress_robots_freeze_modified_date":"","_seopress_robots_custom_modified_date":"","_seopress_robots_canonical":"","_seopress_social_fb_title":"","_seopress_social_fb_desc":"","_seopress_social_fb_img":"","_seopress_social_fb_img_attachment_id":0,"_seopress_social_fb_img_width":0,"_seopress_social_fb_img_height":0,"_seopress_social_twitter_title":"","_seopress_social_twitter_desc":"","_seopress_social_twitter_img":"","_seopress_social_twitter_img_attachment_id":0,"_seopress_social_twitter_img_width":0,"_seopress_social_twitter_img_height":0,"_seopress_redirections_value":"","_seopress_redirections_enabled":"","_seopress_redirections_enabled_regex":"","_seopress_redirections_logged_status":"","_seopress_redirections_param":"","_seopress_redirections_type":0,"_seopress_analysis_target_kw":"","dsgo_overlay_header":false,"dsgo_overlay_header_text_color":"","dsgo_overlay_skip_top_bar":false,"_designsetgo_exclude_llms":false,"footnotes":""},"categories":[10],"tags":[928,929,927,388,926,236],"class_list":["post-2351","post","type-post","status-publish","format-standard","hentry","category-c","tag-cmos","tag-code-snippets","tag-rtc","tag-tools","tag-vxworks-clock-update","tag-weekly-c"],"_links":{"self":[{"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/posts\/2351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/comments?post=2351"}],"version-history":[{"count":0,"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/posts\/2351\/revisions"}],"wp:attachment":[{"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/media?parent=2351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/categories?post=2351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yazilimperver.com\/index.php\/wp-json\/wp\/v2\/tags?post=2351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}