Bottom Page

Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Reading data from serial port as byte array
#1
Hi,

I'm new here and i'm begginer in python programming. I need to convert c# code to python but i stuck when i wanted to read serial data as byte array.

Here is the code:
int _byteToRead = P._serialPort.BytesToRead;
byte[] inBuffer = new byte[_byteToRead];
P._serialPort.Read(inBuffer, 0, _byteToRead); //Reads a number of characters from the System.IO.Ports.SerialPort input buffer and writes them into an array of characters at a given offset.
........................
byte MatchStart = 242; // HEX: F2
byte MatchEnd = 248; // HEX: F8

I don't know how to convert the first 3 lines.

Thanks,
Quote
#2
See here:
https://python-forum.io/Thread-help-with...-to-Python
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  'utf-8' codec can't decode byte 0xda in position 184: invalid continuation byte karkas 7 290 Sep-12-2019, 11:19 PM
Last Post: newbieAuggie2019
  Byte array is sorted when sending via USB daviddlc68 1 114 Aug-16-2019, 10:11 AM
Last Post: wavic
  Pulling & Reading Date from UDF that Compare it to Live Data firebird 4 189 Jul-20-2019, 09:30 AM
Last Post: snippsat
  Reading mixed ASCII/binary serial input N8UR 1 420 Jun-11-2019, 02:49 PM
Last Post: N8UR
  python3 List to array or string to extract data batchenr 4 335 May-28-2019, 01:44 PM
Last Post: buran
  Reading in MYSQL data as integer type Daveinthebigcity 2 257 May-13-2019, 11:30 AM
Last Post: Daveinthebigcity
  Type error when reading in different data types on an __init__ method Dylanmull 3 262 May-09-2019, 02:05 PM
Last Post: buran
  Reading one value from an array in reverse DreamingInsanity 10 515 May-04-2019, 08:14 AM
Last Post: DreamingInsanity
  How can I only receive data from selected serial numbers MasterCATZ 7 395 Apr-20-2019, 08:35 AM
Last Post: MasterCATZ
  Multiple process access to a serial port mkonnov 0 244 Apr-14-2019, 12:42 PM
Last Post: mkonnov

Forum Jump:


Users browsing this thread: 1 Guest(s)