Cypress Semiconductor CY8C21534 Spezifikationen Seite 64

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 69
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 63
Appendix 2
14(15)
// Adds file type to file name
file += ".jpg";
// Opens file access stream
FileStream data = new FileStream(file, FileMode.Open, FileAccess.Read);
// Opens file
FileInfo info = new FileInfo(file);
int len = (int)info.Length;
// Retrieves file size
byte[] bLen = BitConverter.GetBytes(len);
// Sends file size, bytes
writer.Write(bLen, 0, 4);
writer.Flush();
// Sends number of sectors in file
bLen = BitConverter.GetBytes((len / 512) + 1);
writer.Write(bLen);
writer.Write(0);
writer.Flush();
// Displays status
listBox1.Items.Add(" File size sent");
byte[] data2 = new byte[len];
int count = 0, total = 0;
count = data.Read(data2, 0, len);
// Scans incoming bytes, waits for byte 0x53 'S', when schedules MCU is ready for raw
// data
while (sendChar != 0x53)
{
sendChar = reader.ReadChar();
}
// Displays status
listBox1.Items.Add("Sending file...");
// Sends raw data of file
while (total != len)
{
writer.Write(data2, 0, count);
total += count;
}
// Finishes sending data and closes connection, program starts over
writer.Flush();
listBox1.Items.Add(" File sent.");
reader.Close();
writer.Close();
socketStream.Close();
connection.Close();
listBox1.Items.Add("Disconnected.");
listBox1.Items.Add("");
server.Stop();
RunServer();
}
catch(Exception)
Seitenansicht 63
1 2 ... 59 60 61 62 63 64 65 66 67 68 69

Kommentare zu diesen Handbüchern

Keine Kommentare