Bài đăng

STM32F103C8 BLUE PILL ARDUINO SETUP

Hình ảnh
STM32F103C8 BLUE PILL ARDUINO SETUP Level of support Good Bootloader Flash with  [1] Microcontroller STM32F103C8 Flash 64 KB/128 KB RAM 20 KB Clock Speed 72 MHz USB connector Micro-B (varying quality) User LED(s) PC13 (blue; lights when PC13 is LOW) User button(s) None RTC Crystal Yes ST-Link header Yes Voltage regulator RT9193-33 (300 mA) Schematic media:Vcc-gnd.com-STM32F103C8-schematic.pdf  (4.7k R10) media:Stm32f103c8t6_schematic.png  (10k R10) Manufacturer data http://vcc-gnd.com/read.php?tid=369&fid=6 Pinout media:Bluepillpinout.gif http://reblag.dk/wordpress/wp-content/uploads/2016/07/The-Generic-STM32F103-Pinout-Diagram.pdf Dimensions 53.0mm x 22.5mm 1. Burning the bootloader https://wiki.stm32duino.com/index.php?title=Burning_the_bootloader 2. Thêm board stm32f103 Vào File/Preferences. Copy URL  http://dan.drown.org/stm32duino/package_STM32duino_index.json  vào phần additional boards manager URLs  ...

JSON-C Example

JSON-C Example So you want to parse JSON with C? Welcome aboard! First get json-c, configure, compile, and update your ld cache wget http://oss.metaparadigm.com/json-c/json-c-0.9.tar.gz tar xf json-c-0.9.tar.gz cd json-c-0.9 ./configure && make && sudo make install sudo ldconfig Now use one of the test files provided or this example: http://www.jroller.com/RickHigh/entry/json_parsing_with_c_simple cd .. vim json-example.c #include <stdio.h> #include <stdlib.h> #include <stddef.h> #include <string.h> #include "json.h" int main(int argc, char **argv) { struct json_object *new_obj; MC_SET_DEBUG(1); // I added some new lines... not in real program new_obj = json_tokener_parse("/* more difficult test case */ { \"glossary\": { \"title\": \"example glossary\", \"pageCount\": 100, \"GlossDiv\": { \"title\": \"S\", \"GlossList\": [ { \"ID...

Displaying IP address on eth0 interface

Displaying IP address on eth0 interface Awk ifconfig eth0 | awk '/inet addr/{split($2,a,":"); print a[2]}' split function in the above awk command splits the second column based on the delimiter  :  and stores the splitted value into an associative array  a . So  a[2]  holds the value of the second part. sed ifconfig eth0 | sed - n '/inet addr/s/.*inet addr: *\([^[:space:]]\+\).*/\1/p' In basic sed ,  \(...\)  called capturing group which is used to capture the characters. We could refer those captured characters through back-referencing.  \([^[:space:]]\+\)  captures any character but not space one or more times. grep ifconfig eth0 | grep - oP 'inet addr:\K\S+' \K  discards the previously matched characters from printing at the final and  \S+  matches one or more non-space characters. Perl ifconfig eth0 | perl - lane 'print $1 if /inet addr:(\S+)/' One or more non-space characters which are next to th...

Untrack files already added to git repository based on .gitignore

Let’s say you have already added/committed some files to your git repository and you then add them to your .gitignore; these files will still be present in your repository index. This article we will see how to get rid of them. Step 1: Commit all your changes Before proceeding, make sure all your changes are committed, including your .gitignore file. Step 2: Remove everything from the repository To clear your repo, use: git rm -r --cached . rm  is the remove command -r  will allow recursive removal –cached  will only remove files from the index. Your files will still be there. The  .  indicates that all files will be untracked. You can untrack a specific file with  git rm --cached foo.txt  (thanks  @amadeann ). The  rm  command can be unforgiving. If you wish to try what it does beforehand, add the  -n  or  --dry-run  flag to test things out. Step 3: Re add everything git add . Step 4...

Lập trình mạng với module socket trong Python

Socket là gì? Socket là các điểm đầu nút (endpoint) của một kênh giao tiếp song hướng. Các Socket có thể giao tiếp bên trong một tiến trình, giữa các tiến trình trên cùng một thiết bị hoặc giữa các tiến trình trên các lục địa khác nhau. Các Socket có thể được triển khai thông qua các kênh khác nhau: domain, TCP, UDP, … Thư viện  socket  cung cấp các lớp riêng để xử lý các trình truyền tải cũng như một Interface chung để xử lý phần còn lại. Socket có các khái niệm riêng như sau: Khái niệm Miêu tả domain Là family của các giao thức protocol được sử dụng như là kỹ thuật truyền tải. Các giá trị này là các hằng như AF_INET, PF_INET, PF_UNIX, PF_X25, … type Kiểu giao tiếp giữa hai endpoint, đặc trưng là SOCK_STREAM cho các giao thức hướng kêt nối (connection-oriented) và SOCK_DGRAM cho các giao thức không hướng kết nối protocol Đặc trưng là 0, mà có thể được sử dụng để nhận diện một biến thể của một giao thức bên trong một domain hoặc type hostname Định danh của một net...

Sử dụng Xbee

Hình ảnh
Introduction XBees trở thành Transcivers phổ biến vì những lý do sau. Chúng linh hoạt, chúng gửi và nhận data chỉ cần qua Serial port, có nghĩa là chúng tương thích với cả máy tính và vi điều khiển. Highly configurable- bạn có thể mesh mạng bằng hàng chục Xbees hoặc chỉ swapping data. Bạn có thể dùng Xbee để điều khiển robot, hay lắp đặt để giám sát nhiệt độ các phòng. Để kết nối XBee với máy tính bạn cần thêm cổng serial port: Bắt đầu với X-CTU là cách đơn giản nhất để tiếp cận với Xbee X-CTU là phần mềm miễn phí, được cung cấp bởi Digi (nhà sản xuất Xbee), ta dùng nó để cấu hình và quản lý Xbee, kiểm tra mạng Xbee. Link download X-CTU và hướng dẫn cài đặt: https://www.digi.com/support/productdetail?pid=3352&type=utilities Adding XBee Trước khi tiếp tục hãy chắc chắn đã kết nối đúng cách Xbee với máy tính. Kiểm tra Port name. Thêm ảnh kiết nối vào đây Ban đầu sau khi open X-CTU bạn sẽ thấy một cửa sổ như sau: Để add Xbee, click “Add device” icon - - ở ...