Support Requests - CLICK TO READ BEFORE POSTING



Posted by: alowe
04-02-2018, 05:31 PM
Forum: Coding
- Replies (3)

Something about using Linux encourages me to learn C. So I wrote a simple program to output morse code.

I wanted it to play the morse a bit faster but if I reduce the sample lengths any further they fail to play at all. So this looks like it's as far as it will go. Never intended for it to be practical. Just wanted to try something.

I'm not sure if attaching Linux executables is safe or advisable (it isn't on Windows systems). Incase it doesn't work or you want to compile it yourself, here is the code:

Code:
// Compilation: //  gcc -o morse morse.c -lao -ldl -lm #include <stdio.h> #include <unistd.h> #include <string.h> #include <ao/ao.h> #include <math.h> #define bool char #define true 1 #define false 0 #define dot 25200 // length of dot sound #define dash 44100 // length of dash sound #define delay 200000 // delay in microseconds between dots and dashes in morse code const char* morse[] = { ".-", // A "-...", // B "-.-.", // C "-..", // D ".", // E "..-.", // F "--.", // G "....", // H "..", // I ".---", // J "-.-", // K ".-..", // L "--", // M "-.", // N "---", // O ".--.", // P "--.-", // Q ".-.", // R "...", // S "-", // T "..-", // U "...-", // V ".--", // W "-..-", // X "-.--", // Y "--..", // Z "-----", // 0 ".----", // 1 "..---", // 2 "...--", // 3 "....-", // 4 ".....", // 5 "-....", // 6 "--...", // 7 "---..", // 8 "----." // 9 }; void dotdash(char* code, ao_device* device, char* buffer, char audio, char reveal, char suppress) { // exit early if there's nothing to do if (!audio && suppress) return; // play dot and dash sounds for each dot and dash in code for (int i=0; i < strlen(code); i++) { if (audio) { switch (code[i]) { case '.': ao_play(device, buffer, dot); break; case '-': ao_play(device, buffer, dash); break; // ignore other characters } } if (reveal && !suppress) { printf("%c", code[i]); fflush(stdout); } usleep(delay); } if (reveal && !suppress) printf(" "); usleep(delay); } int main(int argc, char** argv) { ao_device* device; ao_sample_format format; char* buffer; float freq = 1000.0; // the pitch of the sound int default_driver, buf_size, sample, i; char ascii, opt, optcount=0; bool audio=false, reveal=false, suppress=false; // read options for (i=1; i<argc; i++) { if (argv[i][0] == '-' && strlen(argv[i]) > 1) { opt = (argv[i][1] >= 65 && argv[i][1] <= 90) ? argv[i][1] + 32 : argv[i][1]; // convert to lower case switch (opt) { case 'a': audio = true; optcount++; break; case 'r': reveal = true; optcount++; break; case 's': suppress=true; optcount++; break; // ignore all unrecognised options } } } // the final argument is assumed to be the text to be translated // initialise default audio driver if (audio) { ao_initialize(); default_driver = ao_default_driver_id();         memset(&format, 0, sizeof(format)); format.bits = 16; format.channels = 2; format.rate = 44100; format.byte_format = AO_FMT_LITTLE; // open audio driver device = ao_open_live(default_driver, &format, NULL); if (device == NULL) { if (!suppress) printf("Error opening audio device.\n"); fprintf(stderr, "Error opening audio device.\n"); } else { // create morse sound buf_size = format.bits/8 * format.channels * format.rate; buffer = calloc(buf_size, sizeof(char)); for (i = 0; i < format.rate; i++) { sample = (int)(0.75 * 32768.0 * sin(2 * M_PI * freq * ((float) i/format.rate))); // left and right channel buffer[4*i] = buffer[4*i+2] = sample & 0xff; buffer[4*i+1] = buffer[4*i+3] = (sample >> 8) & 0xff; } } } // disable audio and reveal options if audio failed to initialise if (device == NULL) { audio = false; reveal = false; } // usage if (argc == 1) { printf("Usage: morse [opt] [text]\n\n"); printf(" -a output audio (requires libao): sudo apt-get install libao-dev\n"); printf(" -r reveal morse as audio is played\n"); printf(" -s suppress text output\n\n"); printf("Translates to international morse code. Put text in quotes if including spaces.\n"); printf("Only alphanumeric characters translated. All other characters are ignored.\n"); // output text translation } else if (argc > optcount + 1) { // regardless of audio, if there is no reveal just print the morse quickly if (!reveal && !suppress) { for (i=0; i < strlen(argv[argc-1]); i++) { ascii = argv[argc-1][i]; if (ascii == 32) { // spaces printf(" "); } else if (ascii >= 48 && ascii <= 57) { // numbers 0 to 9... printf("%s", morse[ascii-48+26]); } else if ( (ascii >= 65 && ascii <= 90) || (ascii >=97 && ascii <= 122) ) { // letters a to z... if ( ascii >= 97 ) ascii -= 32; printf("%s", morse[ascii-65]); } if (ascii != 32 ) printf(" "); } fflush(stdout); } // but if there is audio or the morse is being revealed in morse timing then step though it if (audio || reveal) { for (i=0; i < strlen(argv[argc-1]); i++) { ascii = argv[argc-1][i]; if (ascii == 32) { // spaces if (!suppress) printf(" "); usleep(delay*2); } else if (ascii >= 48 && ascii <= 57) { // numbers 0 to 9... dotdash((char*) morse[ascii-48+26], device, buffer, audio, reveal, suppress); } else if ( (ascii >= 65 && ascii <= 90) || (ascii >=97 && ascii <= 122) ) { // letters a to z... if ( ascii >= 97 ) ascii -= 32; dotdash((char*) morse[ascii-65], device, buffer, audio, reveal, suppress); } } } if (!suppress) printf("\n"); } // close and shutdown if (audio) { ao_close(device); ao_shutdown(); } return (device == NULL) ? 0 : 1; }

I can see things that could be improved but resisting the urge to tinker further. E.g. reveal should still work even if the audio driver fails to load and the final return doesn't need a ternary operator. Must resist urge to tinker...

Expected output:

Code:
Usage: morse [opt] [text] -a output audio (requires libao): sudo apt-get install libao-dev -r reveal morse as audio is played -s suppress text output Translates to international morse code. Put text in quotes if including spaces. Only alphanumeric characters translated. All other characters are ignored.

Any number of options can be given in any order. If using audio, the morse is played slowly enough that you can learn how to recognise the sounds. If you wanted to use it to play fast morse I guess you could sample the raw output into something like Audacity and then speed it up without raising the pitch. If your device doesn't support direct sampling internally then just use a male to male audio jack between the microphone and headphone inputs. Does the job.

Edit:
Have attached an example.mp3 file to show what that the following message sounds like when sped up in Audacity:
"Example of output from the morse program"



Posted by: captnemo
04-02-2018, 09:50 AM
Forum: Network
- No Replies

Dear All:

I have got an issue with subject USB WLAN adapter.  After having made it work using the suggestions/modules addressed here - https://ubuntuforums.org/showthread.php?t=2348667 and here - https://askubuntu.com/questions/820886/p...ect=1&lq=1 I made the following observations:

  1. On a Medion Akoya E1210 running Lubuntu 4.13.0-37-generic (i686) (17.10), the adapter LED works perfectly, indicating any activity as expected; modules installed to get it operational are referred to in the two hyperlinks above;
  2. on a Lenovo ThinkCentre M72e DT system running Linux 4.13.0-37-generic (x86_64) (17.10) the adapter was recognized natively - does NOT indicate any activity, i.e., LED does not blink;
  3. on my DELL Latitude D800 running Linux Lite 3.8 Kernel 4.4.0-118-generic (i686) (16.04), I used the references given in the two hyperlinks above to make it work; the LED does NOT indicate any activity, i.e., LED does NOT blink.


I googled a considerable bit but only found indications for laptops to STOP the blinking of built-in INTEL wireless cards' activity LEDs.

Does anybody out there have a suggestion on how to turn it ON for Linux-based O/Ss?  BTW - on Windows-based machines the adapter LED works as expected.

Thanks for any ideas.
-captnemo




Posted by: GregO
04-01-2018, 04:37 PM
Forum: Start up and Shutdown
- Replies (2)

I'm running the 3.8 version of LL, and I'd like to use an external monitor with my laptop with the lid closed. Is this possible?

I searched here and came up empty. Also I went into Power Manager and tried all selections of "when lid is closed" (was hoping to see do nothing, but not a choice).
I haven't connected an external monitor to it yet to check the functions, but it doesn't seem as if I'll be able to use an external monitor with my laptop lid closed.

Thinking I must have overlooked something.



Posted by: Jocklad
04-01-2018, 01:26 AM
Forum: On Topic
- Replies (15)

Very worrying to see THIS on the Linux Lite Forum. OK just remembered  its the first of April  :o


[url=https://www.linuxliteos.com/forums/[Image: ysuY4lx.png]][Image: ysuY4lx.png]



Posted by: m654321
03-31-2018, 03:51 AM
Forum: Other
- Replies (1)

Some time ago, goldfinger wrote an excellent tutorial explaining how to symlink the directories in the /home partition (i.e. Documents, Downloads, Music, etc) to a separate data drive: see https://www.linuxliteos.com/forums/tutor.../#msg39688

The rationale for doing this is that if the OS drive crashes, the personal data files are separate and safe, i.e. no complicated data file recovery needed.

Towards the end of goldfinger's tutorial, he creates symlinks for the directories, using the following format, where /mnt/DATA is the mount point for the separate data drive:

Code:
ln -s /mnt/DATA/Documents  /home/yourusername

I have a question relating to the above command line: 
Is this format for creating symlinks the same, whether LL is installed as either "/" only, or installed with separate "/" and "/home" partitions?

Many thanks in advance for your comments ...



Posted by: GregO
03-31-2018, 12:19 AM
Forum: Introductions
- Replies (6)

Hello community. I have a few old computers around the house doing nothing so I decided to convert them to Linux machines and Linux Lite was my os of choice to begin with.

I plan to install the OS on a desktop pc that has a hardware issue that I plan to have up and running this week, but for now I've installed it on an older Dell laptop and I couldn't get a wireless connection with it. I submitted a command in Linux, and this is what it returned...

Network: Card-1: Realtek RTL8101/2/6E PCI Express Fast/Gigabit Ethernet controller
driver: r8169
IF: p2p1 state: up speed: 100 Mbps duplex: full
Card-2: Broadcom BCM43142 802.11b/g/n driver: bcma-pci-bridge
IF: N/A state: N/A mac: N/A

I was able to plug a Netgear WN111v2 adapter in and get a wireless connection, but would like to get the laptop working with its built it adapter because the desktop I plan to use has a linksys wmp54g pci adapter and I have my doubts about it connecting, and I really don't want to have to buy another Netgear adapter (but I will if it makes things easier).

Even though I was able to get the Dell's wifi to connect, I am now connected and using Linux Lite, and it works for what I need it for so I'm happy.



Posted by: texla
03-30-2018, 07:53 PM
Forum: Installing Software
- Replies (4)

LinuxLite-3.8 running from usb thumb drive..wanting to add programs (such as launchers to desktop) and have them retain on the usb drive for future boots.
I can down load and install programs but cannot save them for future boots.
Is there a program in linuxlite-3.8 that will achieve this



Posted by: Coastie
03-30-2018, 02:36 PM
Forum: Other
- Replies (7)

Receive the below error when I boot up and when Messenger for Desktop receives a message. I delete all gifs in messages, installed a couple of missing dependencies by Synaptic, and looked unsuccessfully for a way to turn off Java in Messenger for Desktop. Help fixing this problem will be appreciated.

JavaScript error in the main process

TypeError: Invalid Version: undefined
    at new SemVer (/opt/messengerfordesktop/resources/app.asar/node_modules/semver/semver.js:279:11)
    at compare (/opt/messengerfordesktop/resources/app.asar/node_modules/semver/semver.js:566:10)
    at Function.gt (/opt/messengerfordesktop/resources/app.asar/node_modules/semver/semver.js:595:10)
    at /opt/messengerfordesktop/resources/app.asar/scripts/browser/components/auto-updater/base.js:79:49
    at done (/opt/messengerfordesktop/resources/app.asar/node_modules/needle/lib/needle.js:432:14)
    at PassThrough.<anonymous> (/opt/messengerfordesktop/resources/app.asar/node_modules/needle/lib/needle.js:671:11)
    at emitNone (events.js:91:20)
    at PassThrough.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)



Posted by: anastiel
03-30-2018, 12:29 PM
Forum: Other
- Replies (3)

I recently saw that it came out version 4.0 for alpha and I do not want to lose my files is it possible to wait for 4.0 and do update using sudo apt-get dist-upgrade in linux lite 3.8?
if I do not upgrade to 4.0 I will lose support in 3.8? will the programs update normally? chromium etc etc?
thanks support ilove linux lite