Files
timelapse-raspi/old_files/Connexion.py
Kerboul 610d220c3f Refactor and enhance timelapse capture system
- Removed obsolete script `script_SANSDEMARRAGE.sh`.
- Added new `Camera.py` and `Connexion.py` files for camera handling and socket communication.
- Implemented `First_Try.py` for initial camera preview testing.
- Created `Humidity.py` for humidity sensor data acquisition.
- Developed `Send_data_stocked.py` for managing and sending stored data.
- Introduced `Time_Lapse_Connection.py` and `Time_Lapse_NoConnection.py` for connected and offline modes.
- Added `get_from_server.py` for retrieving camera status from the server.
- Updated `sync_offline_data.py` for synchronizing offline data.
- Created `timelapse.service` for managing the timelapse service on Raspberry Pi.
- Established package structure with `__init__.py` and `api_client.py` for API interactions.
- Enhanced `capture.py` for managing image captures and data storage.
- Configured `config.py` for centralized configuration management.
- Developed `sensors.py` for handling environmental sensors and camera operations.
- Implemented `timelapse_offline.py` and `timelapse_online.py` for capturing images in offline and online modes.
2025-04-27 16:45:00 +02:00

38 lines
1.1 KiB
Python

import socket
class MySocket:
"""demonstration class only
- coded for clarity, not efficiency
"""
def __init__(self, sock=None):
if sock is None:
self.sock = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
else:
self.sock = sock
def connect(self, host, port):
self.sock.connect((host, port))
def mysend(self, msg):
totalsent = 0
while totalsent < MSGLEN:
sent = self.sock.send(msg[totalsent:])
if sent == 0:
raise RuntimeError("socket connection broken")
totalsent = totalsent + sent
def myreceive(self):
chunks = []
bytes_recd = 0
while bytes_recd < MSGLEN:
chunk = self.sock.recv(min(MSGLEN - bytes_recd, 2048))
if chunk == b'':
raise RuntimeError("socket connection broken")
chunks.append(chunk)
bytes_recd = bytes_recd + len(chunk)
return b''.join(chunks)
if __name__ == "__main__":
print("bonjour")
MySocket()