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
  Read Data from Serial Port PA3040 3 141 Feb-16-2020, 04:54 AM
Last Post: PA3040
  'utf-8' codec can't decode byte 0xda in position 184: invalid continuation byte karkas 8 6,461 Feb-08-2020, 06:58 PM
Last Post: karkas
  Need help with For Loop logic for reading docx Table column data vintysaw 2 352 Jan-10-2020, 06:36 AM
Last Post: vintysaw
  First Byte of a string is missing while receiving data over TCP Socket shahrukh1987 3 277 Nov-20-2019, 10:34 AM
Last Post: shahrukh1987
  Reading blob data from database by python and store it in .zip format Adityasi 2 256 Nov-18-2019, 05:22 PM
Last Post: ibreeden
  Project, Reading Data from a spreadsheet. Error message!! Shafla 1 273 Sep-27-2019, 10:44 AM
Last Post: buran
  Byte array is sorted when sending via USB daviddlc68 1 271 Aug-16-2019, 10:11 AM
Last Post: wavic
  Pulling & Reading Date from UDF that Compare it to Live Data firebird 4 351 Jul-20-2019, 09:30 AM
Last Post: snippsat
  Reading mixed ASCII/binary serial input N8UR 1 745 Jun-11-2019, 02:49 PM
Last Post: N8UR
  python3 List to array or string to extract data batchenr 4 598 May-28-2019, 01:44 PM
Last Post: buran

Forum Jump:


Users browsing this thread: 1 Guest(s)