منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
rs323 interface vb.net - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : rs323 interface vb.net (/showthread.php?tid=30094)



rs323 interface vb.net - makky - 30-06-19

لو سمحتوا يا جماعة لوعايز اخد بيانات من جهاز بس الجهازده ليه سيستم معين زي بعض الاجهزة في المجال الطبي.لو عايز اخد الداتا واستقبلها بواسطة ال vb.net عن طريق السيريل كابل.ايه الفكرة وازاي بحصل علي البيانات دي وبتوصلني في شكل ايه


RE: rs323 interface vb.net - sniperjawadino - 30-06-19

قم بإضافة أداة SerialPort1      Button1   Textbox1


وضع هذا الكود في Button1 
مع تغيير الإعدادات التي تناسب الآلة  PortName    BaudRate

كود :
       SerialPort1.PortName = COM1
       SerialPort1.BaudRate = 9600
       SerialPort1.Parity = IO.Ports.Parity.None
       SerialPort1.StopBits = IO.Ports.StopBits.One
       SerialPort1.DataBits = 8
       'SerialPort1.Handshake = IO.Ports.Handshake.None
       'SerialPort1.Encoding = System.Text.Encoding.ASCII
       SerialPort1.Open()


ثم ضع هذا الكود في الفورم


كود :
   Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
       ReceivedText(SerialPort1.ReadExisting())    'Automatically called every time a data is received at the SerialPort1
   End Sub
   Delegate Sub SetTextCallback(ByVal [text] As String) 'Added to prevent threading errors during receiveing of data
   Private Sub ReceivedText(ByVal [text] As String)
       'compares the ID of the creating Thread to the ID of the calling Thread
       If Me.rtbReceived.InvokeRequired Then
           Dim x As New SetTextCallback(AddressOf ReceivedText)
           Me.Invoke(x, New Object() {(text)})
       Else
           Me.rtbReceived.Text &= [text]
           Me.TextBox1.Text = [text]
       End If
   End Sub



RE: rs323 interface vb.net - makky - 01-07-19

جزالك الله خيرا اخي.عفوا سؤال .البيانات هستقبلها في صورة ايه يعني لو في رسومات بيانية وارقام.هستبل ده كله في صورة ايه وازاي اقدر اخد البيانات دي علي البرنامج بتاعي


RE: rs323 interface vb.net - sniperjawadino - 01-07-19

حسب معلوماتي السيريل كابل سيرسل لك بيانات على شكل string فقط
يعني أرقام و حروف
و أنت الذي ستوضف هذه البيانات في برنامجك لتعمل رسومات


RE: rs323 interface vb.net - makky - 04-07-19

قرأت برتكول الجهاز. بيقول ان النص هيكون عبارة عن ascii والصور binary.
ازاي اقدر احول الascii لداتا اقدر اتعامل معاها وكذلك ال binary


RE: rs323 interface vb.net - sniperjawadino - 06-07-19

جيد أخي
قم بالخطوة الأولى و هي قراءة البيانات
ثم ضع جزء منها هنا بالمنتدى سأحاول مساعدتك على قد علمي أو أحد الأعضاء الكرام


RE: rs323 interface vb.net - makky - 09-07-19

(30-06-19, 06:44 PM)sniperjawadino كتب : قم بإضافة أداة SerialPort1      Button1   Textbox1


وضع هذا الكود في Button1 
مع تغيير الإعدادات التي تناسب الآلة  PortName    BaudRate

كود :
       SerialPort1.PortName = COM1
       SerialPort1.BaudRate = 9600
       SerialPort1.Parity = IO.Ports.Parity.None
       SerialPort1.StopBits = IO.Ports.StopBits.One
       SerialPort1.DataBits = 8
       'SerialPort1.Handshake = IO.Ports.Handshake.None
       'SerialPort1.Encoding = System.Text.Encoding.ASCII
       SerialPort1.Open()


ثم ضع هذا الكود في الفورم


كود :
   Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
       ReceivedText(SerialPort1.ReadExisting())    'Automatically called every time a data is received at the SerialPort1
   End Sub
   Delegate Sub SetTextCallback(ByVal [text] As String) 'Added to prevent threading errors during receiveing of data
   Private Sub ReceivedText(ByVal [text] As String)
       'compares the ID of the creating Thread to the ID of the calling Thread
       If Me.rtbReceived.InvokeRequired Then
           Dim x As New SetTextCallback(AddressOf ReceivedText)
           Me.Invoke(x, New Object() {(text)})
       Else
           Me.rtbReceived.Text &= [text]
           Me.TextBox1.Text = [text]
       End If
   End Sub

هو ده اداة تيكست بوكس
Me.rtbReceived.Text


RE: rs323 interface vb.net - sniperjawadino - 09-07-19

نعم ممكن إستعمال تيكس بوكس
أنا كنت أستعمل الإثنين TextBox et RichTextBox1 لأعرف الفرق من باب التعلم