-
Notifications
You must be signed in to change notification settings - Fork 0
feature | sprint2 | FRB-171 | 센서 포트 장치에서 읽어들이게 수정 | 정민석 #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
gwangbu-desu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GOOD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the sensor connection flow to automatically detect the USB serial port instead of hardcoding COM3, updates the UI warning message accordingly, and adjusts the simulation configuration ID.
- Dynamically detect and select the serial port in
RealSensor - Remove explicit “COM3” mention from Streamlit warning
- Update
equip_idin the simulation config
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| streamlit_app/app.py | Removed specific COM3 reference from the real_sensor warning |
| simulation_cconfig.json | Changed equip_id value |
| service/sensor/RealSensor.py | Added _find_serial_port() helper and dynamic serial port setup |
Comments suppressed due to low confidence (2)
service/sensor/RealSensor.py:55
- Add unit tests for
_find_serial_port, mockingserial.tools.list_ports.comports()to verify both the successful detection and fallback paths.
def _find_serial_port(self):
simulation_cconfig.json:6
- The
equip_idwas updated to matchzone_id, which likely duplicates the value by mistake. Please verify that the correctequip_idis being used.
"equip_id": "20250507165750-827",
| self.topic_name_humid = self._build_topic(self.zone_id, self.equip_id, self.sensor_id, "humid") | ||
| # 시리얼 포트 설정 | ||
| self.serial_port = 'COM3' # Windows COM 포트 | ||
| self.serial_port = self._find_serial_port() # Windows COM 포트 |
Copilot
AI
May 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider extracting the hardcoded fallback port ('COM3') into a configuration setting or environment variable for easier customization.
| print(f"Available ports: {len(ports)}") | ||
| for port in ports: | ||
| print(f"- {port.device}: {port.description} (manufacturer: {port.manufacturer})") | ||
|
|
||
| # "USB Serial Device"라는 설명이 있는 포트 찾기 | ||
| for port in ports: | ||
| if "USB Serial Device" in port.description: | ||
| print(f"Found USB Serial Device at {port.device}") | ||
| return port.device | ||
|
|
||
| # 찾지 못한 경우 기본값 'COM3' 반환 | ||
| print("USB Serial Device not found. Falling back to COM3.") |
Copilot
AI
May 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace print statements with the project's logging framework to ensure consistent log levels and outputs.
| print(f"Available ports: {len(ports)}") | |
| for port in ports: | |
| print(f"- {port.device}: {port.description} (manufacturer: {port.manufacturer})") | |
| # "USB Serial Device"라는 설명이 있는 포트 찾기 | |
| for port in ports: | |
| if "USB Serial Device" in port.description: | |
| print(f"Found USB Serial Device at {port.device}") | |
| return port.device | |
| # 찾지 못한 경우 기본값 'COM3' 반환 | |
| print("USB Serial Device not found. Falling back to COM3.") | |
| logging.info(f"Available ports: {len(ports)}") | |
| for port in ports: | |
| logging.debug(f"- {port.device}: {port.description} (manufacturer: {port.manufacturer})") | |
| # "USB Serial Device"라는 설명이 있는 포트 찾기 | |
| for port in ports: | |
| if "USB Serial Device" in port.description: | |
| logging.info(f"Found USB Serial Device at {port.device}") | |
| return port.device | |
| # 찾지 못한 경우 기본값 'COM3' 반환 | |
| logging.warning("USB Serial Device not found. Falling back to COM3.") |
| # "USB Serial Device"라는 설명이 있는 포트 찾기 | ||
| for port in ports: | ||
| if "USB Serial Device" in port.description: | ||
| print(f"Found USB Serial Device at {port.device}") | ||
| return port.device | ||
|
|
||
| # 찾지 못한 경우 기본값 'COM3' 반환 | ||
| print("USB Serial Device not found. Falling back to COM3.") | ||
| return 'COM3' |
Copilot
AI
May 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Filtering by the literal string 'USB Serial Device' may not catch all adapter types; consider making this match rule configurable or more robust.
| # "USB Serial Device"라는 설명이 있는 포트 찾기 | |
| for port in ports: | |
| if "USB Serial Device" in port.description: | |
| print(f"Found USB Serial Device at {port.device}") | |
| return port.device | |
| # 찾지 못한 경우 기본값 'COM3' 반환 | |
| print("USB Serial Device not found. Falling back to COM3.") | |
| return 'COM3' | |
| # Configurable keywords for matching port descriptions | |
| match_keywords = getattr(self, "serial_port_keywords", ["USB Serial Device"]) | |
| # Search for a port matching any of the keywords | |
| for port in ports: | |
| if any(keyword.lower() in port.description.lower() for keyword in match_keywords): | |
| print(f"Found matching device at {port.device} (description: {port.description})") | |
| return port.device | |
| # If no matching port is found, fall back to default | |
| print(f"No matching device found. Falling back to default port: 'COM3'.") | |
| return 'COM3' |
📌 PR 제목
feature | sprint2 | FRB-171 | 센서 포트 장치에서 읽어들이게 수정 | 정민석
✨ 변경 사항