DevioLab CRYPTO TRADING AUTOMATION
LIVE
AUTOMATED CRYPTO TRADING • BINANCE
Автоматизуйте свій криптопортфель
Торгові боти DevioLab аналізують крипторинок, автоматично відкривають і закривають позиції та керують вашим портфелем на Binance 24/7.
CRYPTO 80 Bots
BINANCE Spot Trading
TRADING 24 / 7
Спробувати DevioLab
deviolab.com

Програмна реалізація підключення пристрою до інтерфейсу USB

Інформація про навчальний заклад

ВУЗ:
Національний університет Львівська політехніка
Інститут:
Не вказано
Факультет:
Не вказано
Кафедра:
Кафедра електронних обчислювальних машин

Інформація про роботу

Рік:
2015
Тип роботи:
Лабораторна робота
Предмет:
Діагностика комп'ютерних засобів
Група:
КІ

Частина тексту файла (без зображень, графіків і формул):

МІНІСТЕРСТВО ОСВІТИ І НАУКИ УКРАЇНИ НАЦІОНАЛЬНИЙ УНІВЕРСИТЕТ “ЛЬВІВСЬКА ПОЛІТЕХНІКА” КАФЕДРА ЕЛЕКТРОННИХ ОБЧИСЛЮВАЛЬНИХ МАШИН Лабораторна робота №6 з курсу “Діагностика комп’ютерних засобів” на тему: “ Програмна реалізація підключення пристрою до інтерфейсу USB”. Львів-2005 Мета роботи: ознайомитись з основами роботи інтерфейсу USB. Теоретичні відомості: Під час ініціалізації периферійного пристрою шина USB автоматично (за допомогою простих схемотехнічних засобів) визначає швидкість та інші параметри підключеного пристрою. До нього регулярно передаються пакети SOF для синхронізації та присвоєння йому номера. Крім того існують пакети маркери для надання пристрою права передачі інформації чи передачі якихось команд. Виконання роботи: (Передача даних) using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace USBport { public class USBlab : System.Windows.Forms.Form { private System.Windows.Forms.Button InitializeBtn; private System.Windows.Forms.PictureBox markerPic; private System.Windows.Forms.PictureBox dataPic; private System.Windows.Forms.PictureBox SOFpic; private System.Windows.Forms.Label dataLabel; private System.Windows.Forms.Label sofLabel; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox2; private System.ComponentModel.Container components = null; private System.Windows.Forms.TextBox SynchroTextBox; private System.Windows.Forms.TextBox PIDTextBox; private System.Windows.Forms.Label StateLabel; private System.Windows.Forms.TextBox AddrTextBox; private System.Windows.Forms.TextBox ENDPTextBox; private System.Windows.Forms.Label SynchroLabel; private System.Windows.Forms.Label PIDLabel; private System.Windows.Forms.Label ADDRLabel; private System.Windows.Forms.Label ENDLabel; private System.Windows.Forms.TextBox CRC5TextBox; private System.Windows.Forms.Label CRClabel; private System.Windows.Forms.Label Receivelabel; private System.Windows.Forms.TextBox RecSynchTextBox; private System.Windows.Forms.TextBox RecPIDTextBox; private System.Windows.Forms.TextBox RecDataTextBox; private System.Windows.Forms.Label RecSynchLabel; private System.Windows.Forms.Label RecPIDLabel; private System.Windows.Forms.Label RecDataLabel; private System.Windows.Forms.Label markerLabel; private System.Windows.Forms.Button SendButton; private int state = 0; public USBlab() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } static void Main() { Application.Run(new USBlab()); } private void InitializeBtn_Click(object sender, System.EventArgs e) { state++; switch (state) { case 0: break; case 1: this.markerLabel.Visible = false; this.markerPic.Visible = false; this.dataLabel.Visible = false; this.dataPic.Visible = false; this.sofLabel.Visible = false; this.SOFpic.Visible = false; this.StateLabel.Visible = true; this.SynchroTextBox.Visible = true; this.PIDTextBox.Visible = true; this.AddrTextBox.Visible = true; this.ENDPTextBox.Visible = true; this.SynchroLabel.Visible = true; this.PIDLabel.Visible = true; this.ADDRLabel.Visible = true; this.ENDLabel.Visible = true; this.CRC5TextBox.Visible = true; this.CRClabel.Visible = true; this.SynchroTextBox.Text = "01010101"; this.PIDTextBox.Text = "00011110"; this.AddrTextBox.Text = "0000110"; this.ENDPTextBox.Text = "1001"; this.CRC5TextBox.Text = "11010"; this.SynchroLabel.Text = "Синхронізація"; this.PIDLabel.Text = "PID"; this.ADDRLabel.Text = "ADDR"; this.ENDLabel.Text = "ENDP"; this.CRClabel.Text = "CRC"; this.InitializeBtn.Text = "Перейти до передачі пакету SOF"; this.groupBox1.Text = "Опис станів передачі даних"; this.groupBox1.Size = new System.Drawing.Size(378, 256); this.groupBox2.Location = new System.Drawing.Point(8, 272); this.groupBox2.Size = new System.Drawing.Size(378, 72); this.InitializeBtn.Location = new System.Drawing.Point (100, 18); this.Size = new System.Drawing.Size(400, 384); break; case 2: this.markerLabel.Visible = false; this.markerPic.Visible = false; this.dataLabel.Visible = false; this.dataPic.Visible = false; this.sofLabel.Visible = false; this.SOFpic.Visible = false; this.StateLabel.Visible = true; this.StateLabel.Text = "Передача пакету SOF"; this.SynchroTextBox.Visible = true; this.PIDTextBox.Visible = true; this.AddrTextBox.Visible = true; this.ENDPTextBox.Visible = true; this.SynchroLabel.Visible = true; this.PIDLabel.Visible = true; this.ADDRLabel.Visible = true; this.ENDLabel.Visible = true; this.SynchroTextBox.Text = "01010101"; this.PIDTextBox.Text = "01011010"; this.AddrTextBox.Text = "01001011010"; this.ENDPTextBox.Text = "11010"; this.ENDLabel.Text = "CRC"; this.ADDRLabel.Text = "Frame"; this.CRC5TextBox.Visible = false; this.CRClabel.Visible = false; this.InitializeBtn.Text = "Перейти до передачі пакету Data"; this.groupBox1.Text = "Опис станів передачі даних"; this.groupBox1.Size = new System.Drawing.Size(378, 256); this.groupBox2.Location = new System.Drawing.Point(8, 272); this.groupBox2.Size = new System.Drawing.Size(378, 72); this.InitializeBtn.Location = new System.Drawing.Point (100, 18); this.Size = new System.Drawing.Size(400, 384); break; case 3: this.markerLabel.Visible = false; this.markerPic.Visible = false; this.dataLabel.Visible = false; this.dataPic.Visible = false; this.sofLabel.Visible = false; this.SOFpic.Visible = false; this.StateLabel.Visible = true; this.StateLabel.Text = "Передача пакету Data"; this.SynchroTextBox.Visible = true; this.PIDTextBox.Visible = true; this.AddrTextBox.Visible = true; this.ENDPTextBox.Visible = true; this.SynchroLabel.Visible = true; this.PIDLabel.Visible = true; this.ADDRLabel.Visible = true; this.ENDLabel.Visible = true; this.RecDataLabel.Visible = true; this.RecDataTextBox.Visible = true; this.Receivelabel.Visible = true; this.RecPIDLabel.Visible = true; this.RecPIDLabel.Visible = true; this.RecSynchLabel.Visible = true; this.RecSynchTextBox.Visible = true; this.RecPIDTextBox.Visible = true; this.SynchroTextBox.Text = "01010101"; this.PIDTextBox.Text = "00111100"; this.AddrTextBox.Text = ""; this.ENDPTextBox.Text = "1111111111111111"; this.ENDLabel.Text = "CRC"; this.ADDRLabel.Text = "Data"; //this.RecSynchTextBox.Text = "01010101"; //this.RecPIDTextBox.Text = "00101101"; this.InitializeBtn.Location = new System.Drawing.Point(288, 18); this.groupBox1.Size = new System.Drawing.Size(736, 256); this.groupBox2.Location = new System.Drawing.Point(8, 272); this.groupBox2.Size = new System.Drawing.Size(736, 72); this.Size = new System.Drawing.Size(760, 384); this.SendButton.Visible = true; this.InitializeBtn.Text = "Перейти до початкового стану"; break; case 4: this.SendButton.Visible = false; this.InitializeBtn.Text = "Почати симуляцію (передачa пакету Marker)"; this.markerLabel.Visible = true; this.markerPic.Visible = true; this.dataLabel.Visible = true; this.dataPic.Visible = true; this.sofLabel.Visible = true; this.SOFpic.Visible = true; this.StateLabel.Visible = false; this.SynchroTextBox.Visible = false; this.PIDTextBox.Visible = false; this.AddrTextBox.Visible = false; this.ENDPTextBox.Visible = false; this.SynchroLabel.Visible = false; this.PIDLabel.Visible = false; this.ADDRLabel.Visible = false; this.ENDLabel.Visible = false; this.CRC5TextBox.Visible = false; this.CRClabel.Visible = false; this.RecDataLabel.Visible = false; this.RecDataTextBox.Visible = false; this.Receivelabel.Visible = false; this.RecPIDLabel.Visible = false; this.RecPIDLabel.Visible = false; this.RecSynchLabel.Visible = false; this.RecSynchTextBox.Visible = false; this.RecPIDTextBox.Visible = false; this.InitializeBtn.Location = new System.Drawing.Point(288, 18); this.groupBox1.Size = new System.Drawing.Size(736, 432); this.groupBox2.Location = new System.Drawing.Point(8, 448); this.groupBox2.Size = new System.Drawing.Size(736, 72); this.Size = new System.Drawing.Size(760, 560); state = 0; break; } } private void SendButton_Click(object sender, System.EventArgs e) { string tempData = ""; if (AddrTextBox.Text.Length == 0) { MessageBox.Show (this, "Введіть дані для передачі"); this.RecSynchTextBox.Text = ""; this.RecPIDTextBox.Text = ""; this.RecDataTextBox.Text = ""; } else { for (int j=0; j<AddrTextBox.Text.Length; j++) { if (AddrTextBox.Text[j]=='1' || AddrTextBox.Text[j] == '0') { tempData+=AddrTextBox.Text[j]; } else { MessageBox.Show (this, "Дозволені тільки двійкові числа"); this.AddrTextBox.Text = ""; break; } } } this.RecSynchTextBox.Text = "01010101"; this.RecPIDTextBox.Text = "00101101"; this.RecDataTextBox.Text = tempData; tempData = ""; } } }  Висновки: при виконанні лабораторної роботи №6 я ознайомився з основними я принципами роботи інтерфейсу USB.
Антиботан аватар за замовчуванням

2015

Коментарі

Ви не можете залишити коментар. Для цього, будь ласка, увійдіть або зареєструйтесь.

Ділись своїми роботами та отримуй миттєві бонуси!

Нічого не вибрано
0%

Оголошення від адміністратора

Антиботан аватар за замовчуванням

Подякувати Студентському архіву довільною сумою

Admin

26.02.2023 12:38

Дякуємо, що користуєтесь нашим архівом!